Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pymelsec/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class MCError(Exception):
"""

def __init__(self, errorcode):
self.errorcode = f'0x{str(errorcode).rjust(4, "0").upper()}'
if isinstance(errorcode, str):
self.errorcode = int(f'0x{errorcode.rjust(4, "0").upper()}', 16)
elif isinstance(errorcode, int):
self.errorcode = errorcode


def __str__(self):
Expand Down Expand Up @@ -71,6 +74,7 @@ def __str__(self):
elif self.errorcode == 0xC204:
return (f'{self.errorcode}: The connected device is different from the one that requested for '
'unlock processing of the remote password.')
return f'{self.errorcode}: Unknown error.'


class DataTypeError(Exception):
Expand Down