Output backup log on error (#3722)

* Output backup log on error

* Apply suggestions from code review

Co-authored-by: Mike Degatano <michael.degatano@gmail.com>

Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
This commit is contained in:
Pascal Vizeli 2022-07-07 19:20:00 +02:00 committed by GitHub
parent 8b7aa7640c
commit 389aab8d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -681,16 +681,18 @@ class Addon(AddonModel):
try:
command_return = await self.instance.run_inside(command)
if command_return.exit_code != 0:
_LOGGER.error(
"Pre-/Post backup command returned error code: %s",
command_return.exit_code,
_LOGGER.debug(
"Pre-/Post backup command failed with: %s", command_return.output
)
raise AddonsError(
f"Pre-/Post backup command returned error code: {command_return.exit_code}",
_LOGGER.error,
)
raise AddonsError()
except DockerError as err:
_LOGGER.error(
"Failed running pre-/post backup command %s: %s", command, err
)
raise AddonsError() from err
raise AddonsError(
f"Failed running pre-/post backup command {command}: {str(err)}",
_LOGGER.error,
) from err
async def backup(self, tar_file: tarfile.TarFile) -> None:
"""Backup state of an add-on."""