Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Nov 17, 2023
1 parent a8f8cc9 commit f83676f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pynitrokey/nk3/admin_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ def from_int(cls, i: int) -> Optional["FactoryResetStatus"]:
def check(cls, i: int, msg: str) -> None:
status = FactoryResetStatus.from_int(i)
if status != FactoryResetStatus.SUCCESS:
if status:
error = str(status)
else:
error = f"unknown error {i:x}"
raise Exception(f"{msg}: {error}")
if status is None:
raise Exception(f"Unknown error {i:x}")
if status == FactoryResetStatus.NOT_CONFIRMED:
error = "Operation was not confirmed with touch"
elif status == FactoryResetStatus.APP_NOT_ALLOWED:
error = "The application does not support factory reset through nitropy"
elif status == APP_FAILED_PARSE:
error = "The application name must be utf-8"
local_critical(f"{msg}: {error}", support_hint=False)


@enum.unique
Expand Down

0 comments on commit f83676f

Please sign in to comment.