mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Print the exact reason if the WebSocket event to Core fails (#5609)
* Print the exact reason if the WebSocket event to Core fails * Improve error at backup end too, fix tests * Fix text * Address ruff check issue
This commit is contained in:
parent
2078044062
commit
7348745049
@ -359,7 +359,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
|
|||||||
)
|
)
|
||||||
except HomeAssistantWSError as err:
|
except HomeAssistantWSError as err:
|
||||||
raise HomeAssistantBackupError(
|
raise HomeAssistantBackupError(
|
||||||
"Preparing backup of Home Assistant Core failed. Check HA Core logs.",
|
f"Preparing backup of Home Assistant Core failed. Failed to inform HA Core: {str(err)}.",
|
||||||
_LOGGER.error,
|
_LOGGER.error,
|
||||||
) from err
|
) from err
|
||||||
|
|
||||||
@ -376,9 +376,10 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
|
|||||||
resp = await self.websocket.async_send_command(
|
resp = await self.websocket.async_send_command(
|
||||||
{ATTR_TYPE: WSType.BACKUP_END}
|
{ATTR_TYPE: WSType.BACKUP_END}
|
||||||
)
|
)
|
||||||
except HomeAssistantWSError:
|
except HomeAssistantWSError as err:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Error resuming normal operations after backup of Home Assistant Core. Check HA Core logs."
|
"Error resuming normal operations after backup of Home Assistant Core. Failed to inform HA Core: %s.",
|
||||||
|
str(err),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if resp and not resp.get(ATTR_SUCCESS):
|
if resp and not resp.get(ATTR_SUCCESS):
|
||||||
|
@ -90,13 +90,13 @@ async def test_begin_backup_ws_error(coresys: CoreSys):
|
|||||||
"""Test WS error when beginning backup."""
|
"""Test WS error when beginning backup."""
|
||||||
# pylint: disable-next=protected-access
|
# pylint: disable-next=protected-access
|
||||||
coresys.homeassistant.websocket._client.async_send_command.side_effect = (
|
coresys.homeassistant.websocket._client.async_send_command.side_effect = (
|
||||||
HomeAssistantWSConnectionError
|
HomeAssistantWSConnectionError("Connection was closed")
|
||||||
)
|
)
|
||||||
with (
|
with (
|
||||||
patch.object(HomeAssistantWebSocket, "_can_send", return_value=True),
|
patch.object(HomeAssistantWebSocket, "_can_send", return_value=True),
|
||||||
pytest.raises(
|
pytest.raises(
|
||||||
HomeAssistantBackupError,
|
HomeAssistantBackupError,
|
||||||
match="Preparing backup of Home Assistant Core failed. Check HA Core logs.",
|
match="Preparing backup of Home Assistant Core failed. Failed to inform HA Core: Connection was closed.",
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
await coresys.homeassistant.begin_backup()
|
await coresys.homeassistant.begin_backup()
|
||||||
@ -106,13 +106,13 @@ async def test_end_backup_ws_error(coresys: CoreSys, caplog: pytest.LogCaptureFi
|
|||||||
"""Test WS error when ending backup."""
|
"""Test WS error when ending backup."""
|
||||||
# pylint: disable-next=protected-access
|
# pylint: disable-next=protected-access
|
||||||
coresys.homeassistant.websocket._client.async_send_command.side_effect = (
|
coresys.homeassistant.websocket._client.async_send_command.side_effect = (
|
||||||
HomeAssistantWSConnectionError
|
HomeAssistantWSConnectionError("Connection was closed")
|
||||||
)
|
)
|
||||||
with patch.object(HomeAssistantWebSocket, "_can_send", return_value=True):
|
with patch.object(HomeAssistantWebSocket, "_can_send", return_value=True):
|
||||||
await coresys.homeassistant.end_backup()
|
await coresys.homeassistant.end_backup()
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
"Error resuming normal operations after backup of Home Assistant Core. Check HA Core logs."
|
"Error resuming normal operations after backup of Home Assistant Core. Failed to inform HA Core: Connection was closed."
|
||||||
in caplog.text
|
in caplog.text
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user