Skip to content

Commit

Permalink
Handling addtional API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ollo69 committed Oct 14, 2023
1 parent 2a4f013 commit 64ff693
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/smartthinq_sensors/wideq/core_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
"0106": exc.NotConnectedError,
"0100": exc.FailedRequestError,
"0110": exc.InvalidCredentialError,
# "9999": exc.NotConnectedError, # This come as "other errors", we manage as not connected.
9000: exc.InvalidRequestError, # Surprisingly, an integer (not a string).
"9995": exc.FailedRequestError, # This come as "other errors", we manage as not FailedRequestError.
"9999": exc.FailedRequestError, # This come as "other errors", we manage as not FailedRequestError.
}

DEFAULT_TOKEN_VALIDITY = 3600 # seconds
Expand Down Expand Up @@ -354,7 +354,7 @@ def _manage_lge_result(result: dict, is_api_v2=False) -> dict:
if "resultCode" in result:
code = result["resultCode"]
if code != "0000":
message = result.get("result") or "ThinQ APIv2 unknown error"
message = result.get("result") or "ThinQ APIv2 error"
if code in API2_ERRORS:
raise API2_ERRORS[code](message)
raise exc.APIError(message, code)
Expand All @@ -368,7 +368,7 @@ def _manage_lge_result(result: dict, is_api_v2=False) -> dict:
if "returnCd" in msg:
code = msg["returnCd"]
if code != "0000":
message = msg.get("returnMsg") or "ThinQ APIv1 unknown error"
message = msg.get("returnMsg") or "ThinQ APIv1 error"
if code in API2_ERRORS:
raise API2_ERRORS[code](message)
raise exc.APIError(message, code)
Expand Down

0 comments on commit 64ff693

Please sign in to comment.