Add optional error code to exceptions (#585)

This commit is contained in:
sdb9696
2023-12-20 19:16:23 +00:00
committed by GitHub
parent 6819c746d7
commit b66347116f
3 changed files with 22 additions and 8 deletions

View File

@@ -130,14 +130,14 @@ class AesTransport(BaseTransport):
return
msg = f"{msg}: {self._host}: {error_code.name}({error_code.value})"
if error_code in SMART_TIMEOUT_ERRORS:
raise TimeoutException(msg)
raise TimeoutException(msg, error_code=error_code)
if error_code in SMART_RETRYABLE_ERRORS:
raise RetryableException(msg)
raise RetryableException(msg, error_code=error_code)
if error_code in SMART_AUTHENTICATION_ERRORS:
self._handshake_done = False
self._login_token = None
raise AuthenticationException(msg)
raise SmartDeviceException(msg)
raise AuthenticationException(msg, error_code=error_code)
raise SmartDeviceException(msg, error_code=error_code)
async def send_secure_passthrough(self, request: str):
"""Send encrypted message as passthrough."""