From 8c4c2428b124a477bef1dc2926d946dcc9d9a5ee Mon Sep 17 00:00:00 2001 From: Austin Mroczek Date: Wed, 4 Dec 2024 18:50:34 +0000 Subject: [PATCH] handle empty response --- total_connect_client/const.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/total_connect_client/const.py b/total_connect_client/const.py index 5d0a666..ef7f8fe 100644 --- a/total_connect_client/const.py +++ b/total_connect_client/const.py @@ -2,7 +2,7 @@ from enum import Enum -from .exceptions import BadResultCodeError +from .exceptions import BadResultCodeError, ServiceUnavailable class ArmType(Enum): @@ -149,6 +149,9 @@ class _ResultCode(Enum): def from_response(response_dict): try: return _ResultCode(response_dict["ResultCode"]) + except TypeError: + # sometimes when there are server issues, it returns empty responses - see issue #228 + raise ServiceUnavailable(f"Server returned empty response, check server status at {STATUS_URL}") from None except ValueError: raise BadResultCodeError( f"unknown result code {response_dict['ResultCode']}", response_dict @@ -178,3 +181,5 @@ def from_response(response_dict): PROJECT_URL = "https://github.com/craigjmidwinter/total-connect-client" + +STATUS_URL = "https://status.resideo.com/" \ No newline at end of file