Add error handling to hassio issues (#94951)

This commit is contained in:
epenet 2023-06-21 11:17:11 +02:00 committed by GitHub
parent 1d18fdf7bd
commit 60b78f4648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -306,7 +306,11 @@ class SupervisorIssues:
async def update(self) -> None:
"""Update issues from Supervisor resolution center."""
data = await self._client.get_resolution_info()
try:
data = await self._client.get_resolution_info()
except HassioAPIError as err:
_LOGGER.error("Failed to update supervisor issues: %r", err)
return
self.unhealthy_reasons = set(data[ATTR_UNHEALTHY])
self.unsupported_reasons = set(data[ATTR_UNSUPPORTED])

View File

@ -715,3 +715,21 @@ async def test_supervisor_remove_missing_issue_without_error(
msg = await client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
async def test_system_is_not_ready(
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Ensure hassio starts despite error."""
aioclient_mock.get(
"http://127.0.0.1/resolution/info",
json={
"result": "",
"message": "System is not ready with state: setup",
},
)
assert await async_setup_component(hass, "hassio", {})
assert "Failed to update supervisor issues" in caplog.text