Add error handling to hassio issues (#94951)
This commit is contained in:
parent
1d18fdf7bd
commit
60b78f4648
2 changed files with 23 additions and 1 deletions
|
@ -306,7 +306,11 @@ class SupervisorIssues:
|
||||||
|
|
||||||
async def update(self) -> None:
|
async def update(self) -> None:
|
||||||
"""Update issues from Supervisor resolution center."""
|
"""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.unhealthy_reasons = set(data[ATTR_UNHEALTHY])
|
||||||
self.unsupported_reasons = set(data[ATTR_UNSUPPORTED])
|
self.unsupported_reasons = set(data[ATTR_UNSUPPORTED])
|
||||||
|
|
||||||
|
|
|
@ -715,3 +715,21 @@ async def test_supervisor_remove_missing_issue_without_error(
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
await hass.async_block_till_done()
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue