mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add exception translations for GIOS integration (#141006)
Add exception translations
This commit is contained in:
parent
a835c85f59
commit
70ed120c6e
@ -44,7 +44,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: GiosConfigEntry) -> bool
|
|||||||
try:
|
try:
|
||||||
gios = await Gios.create(websession, station_id)
|
gios = await Gios.create(websession, station_id)
|
||||||
except (GiosError, ConnectionError, ClientConnectorError) as err:
|
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)
|
coordinator = GiosDataUpdateCoordinator(hass, entry, gios)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
@ -57,4 +57,11 @@ class GiosDataUpdateCoordinator(DataUpdateCoordinator[GiosSensors]):
|
|||||||
async with asyncio.timeout(API_TIMEOUT):
|
async with asyncio.timeout(API_TIMEOUT):
|
||||||
return await self.gios.async_update()
|
return await self.gios.async_update()
|
||||||
except (GiosError, ClientConnectorError) as error:
|
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…
x
Reference in New Issue
Block a user