mirror of
https://github.com/home-assistant/core.git
synced 2026-12-06 05:38:06 -04:00
Add missing exception translations to minecraft_server (#187009)
This commit is contained in:
@@ -109,9 +109,7 @@ async def async_migrate_entry(
|
||||
await api.async_initialize()
|
||||
except MinecraftServerAddressError as error:
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="address_lookup_failed",
|
||||
translation_placeholders={"host": config_data[CONF_HOST]},
|
||||
translation_domain=DOMAIN, translation_key="address_lookup_failed"
|
||||
) from error
|
||||
|
||||
_LOGGER.debug(
|
||||
|
||||
@@ -18,6 +18,7 @@ from .api import (
|
||||
MinecraftServerNotInitializedError,
|
||||
MinecraftServerType,
|
||||
)
|
||||
from .const import DOMAIN
|
||||
|
||||
type MinecraftServerConfigEntry = ConfigEntry[MinecraftServerCoordinator]
|
||||
|
||||
@@ -51,18 +52,18 @@ class MinecraftServerCoordinator(DataUpdateCoordinator[MinecraftServerData]):
|
||||
async def _async_setup(self) -> None:
|
||||
"""Set up the Minecraft Server data coordinator."""
|
||||
|
||||
# Create API instance.
|
||||
self._api = MinecraftServer(
|
||||
self.hass,
|
||||
self.config_entry.data.get(CONF_TYPE, MinecraftServerType.JAVA_EDITION),
|
||||
self.config_entry.data[CONF_ADDRESS],
|
||||
)
|
||||
|
||||
# Initialize API instance.
|
||||
try:
|
||||
await self._api.async_initialize()
|
||||
except MinecraftServerAddressError as error:
|
||||
raise ConfigEntryNotReady(f"Initialization failed: {error}") from error
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN, translation_key="address_lookup_failed"
|
||||
) from error
|
||||
|
||||
@override
|
||||
async def _async_update_data(self) -> MinecraftServerData:
|
||||
@@ -73,4 +74,6 @@ class MinecraftServerCoordinator(DataUpdateCoordinator[MinecraftServerData]):
|
||||
MinecraftServerConnectionError,
|
||||
MinecraftServerNotInitializedError,
|
||||
) as error:
|
||||
raise UpdateFailed(error) from error
|
||||
raise UpdateFailed(
|
||||
translation_domain=DOMAIN, translation_key="data_update_failed"
|
||||
) from error
|
||||
|
||||
@@ -88,7 +88,7 @@ rules:
|
||||
entity-device-class: done
|
||||
entity-disabled-by-default: done
|
||||
entity-translations: done
|
||||
exception-translations: todo
|
||||
exception-translations: done
|
||||
icon-translations: done
|
||||
reconfiguration-flow: todo
|
||||
repair-issues:
|
||||
|
||||
@@ -59,7 +59,10 @@
|
||||
},
|
||||
"exceptions": {
|
||||
"address_lookup_failed": {
|
||||
"message": "Unable to look up the address of Minecraft server {host}"
|
||||
"message": "Unable to look up the address of the Minecraft server"
|
||||
},
|
||||
"data_update_failed": {
|
||||
"message": "A connection error occurred while updating the Minecraft server data"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,5 +338,5 @@ async def test_entry_migration_v3_failure(
|
||||
assert v1_mock_config_entry.state is ConfigEntryState.MIGRATION_ERROR
|
||||
assert (
|
||||
v1_mock_config_entry.reason
|
||||
== f"Unable to look up the address of Minecraft server {TEST_HOST}"
|
||||
== "Unable to look up the address of the Minecraft server"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user