Skip to content
Snippets Groups Projects
Unverified Commit 13dfd27b authored by Martin Hjelmare's avatar Martin Hjelmare Committed by GitHub
Browse files

Clean Home Connect error handling (#139817)

parent 1fb02944
No related branches found
No related tags found
No related merge requests found
...@@ -266,7 +266,7 @@ class HomeConnectCoordinator( ...@@ -266,7 +266,7 @@ class HomeConnectCoordinator(
_LOGGER.debug( _LOGGER.debug(
"Non-breaking error (%s) while listening for events," "Non-breaking error (%s) while listening for events,"
" continuing in %s seconds", " continuing in %s seconds",
type(error).__name__, error,
retry_time, retry_time,
) )
await asyncio.sleep(retry_time) await asyncio.sleep(retry_time)
...@@ -343,9 +343,7 @@ class HomeConnectCoordinator( ...@@ -343,9 +343,7 @@ class HomeConnectCoordinator(
_LOGGER.debug( _LOGGER.debug(
"Error fetching settings for %s: %s", "Error fetching settings for %s: %s",
appliance.ha_id, appliance.ha_id,
error error,
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
) )
settings = {} settings = {}
try: try:
...@@ -357,9 +355,7 @@ class HomeConnectCoordinator( ...@@ -357,9 +355,7 @@ class HomeConnectCoordinator(
_LOGGER.debug( _LOGGER.debug(
"Error fetching status for %s: %s", "Error fetching status for %s: %s",
appliance.ha_id, appliance.ha_id,
error error,
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
) )
status = {} status = {}
...@@ -373,9 +369,7 @@ class HomeConnectCoordinator( ...@@ -373,9 +369,7 @@ class HomeConnectCoordinator(
_LOGGER.debug( _LOGGER.debug(
"Error fetching programs for %s: %s", "Error fetching programs for %s: %s",
appliance.ha_id, appliance.ha_id,
error error,
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
) )
else: else:
programs.extend(all_programs.programs) programs.extend(all_programs.programs)
...@@ -465,9 +459,7 @@ class HomeConnectCoordinator( ...@@ -465,9 +459,7 @@ class HomeConnectCoordinator(
_LOGGER.debug( _LOGGER.debug(
"Error fetching options for %s: %s", "Error fetching options for %s: %s",
ha_id, ha_id,
error error,
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
) )
return {} return {}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import re import re
from aiohomeconnect.model.error import HomeConnectApiError, HomeConnectError from aiohomeconnect.model.error import HomeConnectError
RE_CAMEL_CASE = re.compile(r"(?<!^)(?=[A-Z])|(?=\d)(?<=\D)") RE_CAMEL_CASE = re.compile(r"(?<!^)(?=[A-Z])|(?=\d)(?<=\D)")
...@@ -11,11 +11,7 @@ def get_dict_from_home_connect_error( ...@@ -11,11 +11,7 @@ def get_dict_from_home_connect_error(
err: HomeConnectError, err: HomeConnectError,
) -> dict[str, str]: ) -> dict[str, str]:
"""Return a translation string from a Home Connect error.""" """Return a translation string from a Home Connect error."""
return { return {"error": str(err)}
"error": str(err)
if isinstance(err, HomeConnectApiError)
else type(err).__name__
}
def bsh_key_to_translation_key(bsh_key: str) -> str: def bsh_key_to_translation_key(bsh_key: str) -> str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment