Code quality improvement for evohome (#43678)

This commit is contained in:
David Bonnes
2020-11-27 08:28:05 +00:00
committed by GitHub
parent c2cc605343
commit 5e3f4954f7

View File

@@ -145,7 +145,6 @@ def _handle_exception(err) -> bool:
"Message is: %s",
err,
)
return False
except aiohttp.ClientConnectionError:
# this appears to be a common occurrence with the vendor's servers
@@ -155,7 +154,6 @@ def _handle_exception(err) -> bool:
"Message is: %s",
err,
)
return False
except aiohttp.ClientResponseError:
if err.status == HTTP_SERVICE_UNAVAILABLE:
@@ -163,16 +161,15 @@ def _handle_exception(err) -> bool:
"The vendor says their server is currently unavailable. "
"Check the vendor's service status page"
)
return False
if err.status == HTTP_TOO_MANY_REQUESTS:
elif err.status == HTTP_TOO_MANY_REQUESTS:
_LOGGER.warning(
"The vendor's API rate limit has been exceeded. "
"If this message persists, consider increasing the %s",
CONF_SCAN_INTERVAL,
)
return False
else:
raise # we don't expect/handle any other Exceptions
@@ -427,7 +424,7 @@ class EvoBroker:
try:
result = await api_function
except (aiohttp.ClientError, evohomeasync2.AuthenticationError) as err:
if not _handle_exception(err):
_handle_exception(err)
return
if update_state: # wait a moment for system to quiesce before updating state