Improve user-facing error messages in HomeWizard Energy (#104547)
This commit is contained in:
parent
670e5a2eae
commit
321b24b146
5 changed files with 51 additions and 10 deletions
|
@ -8,6 +8,7 @@ from homewizard_energy.errors import DisabledError, RequestError
|
|||
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import HomeWizardEntity
|
||||
|
||||
_HomeWizardEntityT = TypeVar("_HomeWizardEntityT", bound=HomeWizardEntity)
|
||||
|
@ -30,11 +31,19 @@ def homewizard_exception_handler(
|
|||
try:
|
||||
await func(self, *args, **kwargs)
|
||||
except RequestError as ex:
|
||||
raise HomeAssistantError from ex
|
||||
raise HomeAssistantError(
|
||||
"An error occurred while communicating with HomeWizard device",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="communication_error",
|
||||
) from ex
|
||||
except DisabledError as ex:
|
||||
await self.hass.config_entries.async_reload(
|
||||
self.coordinator.config_entry.entry_id
|
||||
)
|
||||
raise HomeAssistantError from ex
|
||||
raise HomeAssistantError(
|
||||
"The local API of the HomeWizard device is disabled",
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="api_disabled",
|
||||
) from ex
|
||||
|
||||
return handler
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue