Add exception translations for GIOS integration (#141006)
Add exception translationspull/141011/head
parent
a835c85f59
commit
70ed120c6e
|
@ -44,7 +44,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: GiosConfigEntry) -> bool
|
|||
try:
|
||||
gios = await Gios.create(websession, station_id)
|
||||
except (GiosError, ConnectionError, ClientConnectorError) as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cannot_connect",
|
||||
translation_placeholders={
|
||||
"entry": entry.title,
|
||||
"error": repr(err),
|
||||
},
|
||||
) from err
|
||||
|
||||
coordinator = GiosDataUpdateCoordinator(hass, entry, gios)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
|
|
@ -57,4 +57,11 @@ class GiosDataUpdateCoordinator(DataUpdateCoordinator[GiosSensors]):
|
|||
async with asyncio.timeout(API_TIMEOUT):
|
||||
return await self.gios.async_update()
|
||||
except (GiosError, ClientConnectorError) as error:
|
||||
raise UpdateFailed(error) from error
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="update_error",
|
||||
translation_placeholders={
|
||||
"entry": self.config_entry.title,
|
||||
"error": repr(error),
|
||||
},
|
||||
) from error
|
||||
|
|
|
@ -170,5 +170,13 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"cannot_connect": {
|
||||
"message": "An error occurred while connecting to the GIOS API for {entry}: {error}"
|
||||
},
|
||||
"update_error": {
|
||||
"message": "An error occurred while retrieving data from the GIOS API for {entry}: {error}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue