mirror of
https://github.com/borgbackup/borg.git
synced 2026-04-28 09:40:07 -04:00
move Backup*Error to errors module
This commit is contained in:
parent
482ac47ed8
commit
c2e8bb0468
2 changed files with 37 additions and 36 deletions
|
|
@ -25,6 +25,7 @@ from .crypto.key import key_factory, UnsupportedPayloadError
|
|||
from .compress import Compressor, CompressionSpec
|
||||
from .constants import * # NOQA
|
||||
from .crypto.low_level import IntegrityError as IntegrityErrorBase
|
||||
from .helpers import BackupError, BackupOSError, BackupRaceConditionError
|
||||
from .hashindex import ChunkIndex, ChunkIndexEntry, CacheSynchronizer
|
||||
from .helpers import Manifest
|
||||
from .helpers import hardlinkable
|
||||
|
|
@ -177,42 +178,6 @@ def is_special(mode):
|
|||
return stat.S_ISBLK(mode) or stat.S_ISCHR(mode) or stat.S_ISFIFO(mode)
|
||||
|
||||
|
||||
class BackupError(Exception):
|
||||
"""
|
||||
Exception raised for non-OSError-based exceptions while accessing backup files.
|
||||
"""
|
||||
|
||||
|
||||
class BackupRaceConditionError(BackupError):
|
||||
"""
|
||||
Exception raised when encountering a critical race condition while trying to back up a file.
|
||||
"""
|
||||
|
||||
|
||||
class BackupOSError(Exception):
|
||||
"""
|
||||
Wrapper for OSError raised while accessing backup files.
|
||||
|
||||
Borg does different kinds of IO, and IO failures have different consequences.
|
||||
This wrapper represents failures of input file or extraction IO.
|
||||
These are non-critical and are only reported (exit code = 1, warning).
|
||||
|
||||
Any unwrapped IO error is critical and aborts execution (for example repository IO failure).
|
||||
"""
|
||||
def __init__(self, op, os_error):
|
||||
self.op = op
|
||||
self.os_error = os_error
|
||||
self.errno = os_error.errno
|
||||
self.strerror = os_error.strerror
|
||||
self.filename = os_error.filename
|
||||
|
||||
def __str__(self):
|
||||
if self.op:
|
||||
return f'{self.op}: {self.os_error}'
|
||||
else:
|
||||
return str(self.os_error)
|
||||
|
||||
|
||||
class BackupIO:
|
||||
op = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -104,3 +104,39 @@ class BackupExcWarning(BorgWarning):
|
|||
exit_mcode = 102
|
||||
|
||||
# TODO: override exit_code and compute the exit code based on the wrapped exception.
|
||||
|
||||
|
||||
class BackupError(Exception):
|
||||
"""
|
||||
Exception raised for non-OSError-based exceptions while accessing backup files.
|
||||
"""
|
||||
|
||||
|
||||
class BackupRaceConditionError(BackupError):
|
||||
"""
|
||||
Exception raised when encountering a critical race condition while trying to back up a file.
|
||||
"""
|
||||
|
||||
|
||||
class BackupOSError(Exception):
|
||||
"""
|
||||
Wrapper for OSError raised while accessing backup files.
|
||||
|
||||
Borg does different kinds of IO, and IO failures have different consequences.
|
||||
This wrapper represents failures of input file or extraction IO.
|
||||
These are non-critical and are only reported (exit code = 1, warning).
|
||||
|
||||
Any unwrapped IO error is critical and aborts execution (for example repository IO failure).
|
||||
"""
|
||||
def __init__(self, op, os_error):
|
||||
self.op = op
|
||||
self.os_error = os_error
|
||||
self.errno = os_error.errno
|
||||
self.strerror = os_error.strerror
|
||||
self.filename = os_error.filename
|
||||
|
||||
def __str__(self):
|
||||
if self.op:
|
||||
return f'{self.op}: {self.os_error}'
|
||||
else:
|
||||
return str(self.os_error)
|
||||
|
|
|
|||
Loading…
Reference in a new issue