diff --git a/pymelsec/exceptions.py b/pymelsec/exceptions.py index 591e238..3011e29 100644 --- a/pymelsec/exceptions.py +++ b/pymelsec/exceptions.py @@ -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): @@ -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):