Skip to content

Commit

Permalink
more detailled warnings for source file OSErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Nov 15, 2023
1 parent d56c8ea commit 2ed959a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/borg/helpers/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import errno
import os

from ..constants import * # NOQA
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit 2ed959a

Please sign in to comment.