Don't log errors when raising a backup exception in Google Drive (#136916)

This commit is contained in:
tronikos
2025-01-30 19:21:49 +01:00
committed by Bram Kragten
parent 613f0add76
commit 08bb027eac
2 changed files with 7 additions and 12 deletions
@@ -80,16 +80,14 @@ class GoogleDriveBackupAgent(BackupAgent):
try:
await self._client.async_upload_backup(open_stream, backup)
except (GoogleDriveApiError, HomeAssistantError, TimeoutError) as err:
_LOGGER.error("Upload backup error: %s", err)
raise BackupAgentError("Failed to upload backup") from err
raise BackupAgentError(f"Failed to upload backup: {err}") from err
async def async_list_backups(self, **kwargs: Any) -> list[AgentBackup]:
"""List backups."""
try:
return await self._client.async_list_backups()
except (GoogleDriveApiError, HomeAssistantError, TimeoutError) as err:
_LOGGER.error("List backups error: %s", err)
raise BackupAgentError("Failed to list backups") from err
raise BackupAgentError(f"Failed to list backups: {err}") from err
async def async_get_backup(
self,
@@ -121,9 +119,7 @@ class GoogleDriveBackupAgent(BackupAgent):
stream = await self._client.async_download(file_id)
return ChunkAsyncStreamIterator(stream)
except (GoogleDriveApiError, HomeAssistantError, TimeoutError) as err:
_LOGGER.error("Download backup error: %s", err)
raise BackupAgentError("Failed to download backup") from err
_LOGGER.error("Download backup_id: %s not found", backup_id)
raise BackupAgentError(f"Failed to download backup: {err}") from err
raise BackupAgentError("Backup not found")
async def async_delete_backup(
@@ -143,5 +139,4 @@ class GoogleDriveBackupAgent(BackupAgent):
await self._client.async_delete(file_id)
_LOGGER.debug("Deleted backup_id: %s", backup_id)
except (GoogleDriveApiError, HomeAssistantError, TimeoutError) as err:
_LOGGER.error("Delete backup error: %s", err)
raise BackupAgentError("Failed to delete backup") from err
raise BackupAgentError(f"Failed to delete backup: {err}") from err
+3 -3
View File
@@ -141,7 +141,7 @@ async def test_agents_list_backups_fail(
assert response["success"]
assert response["result"]["backups"] == []
assert response["result"]["agent_errors"] == {
TEST_AGENT_ID: "Failed to list backups"
TEST_AGENT_ID: "Failed to list backups: some error"
}
@@ -381,7 +381,7 @@ async def test_agents_upload_fail(
await hass.async_block_till_done()
assert resp.status == 201
assert "Upload backup error: some error" in caplog.text
assert "Failed to upload backup: some error" in caplog.text
async def test_agents_delete(
@@ -430,7 +430,7 @@ async def test_agents_delete_fail(
assert response["success"]
assert response["result"] == {
"agent_errors": {TEST_AGENT_ID: "Failed to delete backup"}
"agent_errors": {TEST_AGENT_ID: "Failed to delete backup: some error"}
}