Clean Home Connect error handling (#139817)

This commit is contained in:
Martin Hjelmare 2025-03-05 09:07:45 +01:00 committed by GitHub
parent 1fb02944b7
commit 13dfd27b7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 19 deletions

View File

@ -266,7 +266,7 @@ class HomeConnectCoordinator(
_LOGGER.debug(
"Non-breaking error (%s) while listening for events,"
" continuing in %s seconds",
type(error).__name__,
error,
retry_time,
)
await asyncio.sleep(retry_time)
@ -343,9 +343,7 @@ class HomeConnectCoordinator(
_LOGGER.debug(
"Error fetching settings for %s: %s",
appliance.ha_id,
error
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
error,
)
settings = {}
try:
@ -357,9 +355,7 @@ class HomeConnectCoordinator(
_LOGGER.debug(
"Error fetching status for %s: %s",
appliance.ha_id,
error
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
error,
)
status = {}
@ -373,9 +369,7 @@ class HomeConnectCoordinator(
_LOGGER.debug(
"Error fetching programs for %s: %s",
appliance.ha_id,
error
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
error,
)
else:
programs.extend(all_programs.programs)
@ -465,9 +459,7 @@ class HomeConnectCoordinator(
_LOGGER.debug(
"Error fetching options for %s: %s",
ha_id,
error
if isinstance(error, HomeConnectApiError)
else type(error).__name__,
error,
)
return {}

View File

@ -2,7 +2,7 @@
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)")
@ -11,11 +11,7 @@ def get_dict_from_home_connect_error(
err: HomeConnectError,
) -> dict[str, str]:
"""Return a translation string from a Home Connect error."""
return {
"error": str(err)
if isinstance(err, HomeConnectApiError)
else type(err).__name__
}
return {"error": str(err)}
def bsh_key_to_translation_key(bsh_key: str) -> str: