From 2fda86ce61d61eba6360095de441c7b825ab5213 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 15 Nov 2023 22:39:42 +0100 Subject: [PATCH] more detailled warnings for source file OSErrors --- src/borg/helpers/errors.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/borg/helpers/errors.py b/src/borg/helpers/errors.py index d808c4c72..6d34b60d3 100644 --- a/src/borg/helpers/errors.py +++ b/src/borg/helpers/errors.py @@ -1,3 +1,4 @@ +import errno import os from ..constants import * # NOQA @@ -108,6 +109,27 @@ class BackupOSWarning(BorgWarning): """{}: {}""" exit_mcode = 104 + @property + def exit_code(self): + if not modern_ec: + return EXIT_WARNING + exc = self.args[1] + assert isinstance(exc, BackupOSError) + if exc.errno in (errno.EPERM, errno.EACCES, ): + return PermissionWarning.exit_mcode + elif exc.errno in (errno.EIO, ): + return IOWarning.exit_mcode + else: + return self.exit_mcode + + +class PermissionWarning(BorgWarning): + exit_mcode = 105 + + +class IOWarning(BorgWarning): + exit_mcode = 106 + class BackupError(Exception): """