Coverage for b4_backup/exceptions.py: 100%
14 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-18 22:40 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-18 22:40 +0000
1"""Contains all custom exceptions used in this program."""
4class BaseBtrfsBackupError(Exception):
5 """Base of all custom exceptions."""
8class FailedProcessError(BaseBtrfsBackupError):
9 """Raised, if a process returns a non-zero return code."""
11 def __init__(self, cmd: list[str], stdout: str = "", stderr: str = ""):
12 """
13 Args:
14 cmd: failed command.
15 stdout: standard output of that process.
16 stderr: standard error of that process.
17 """
18 self.cmd = cmd
19 self.stdout = stdout
20 self.stderr = stderr
22 super().__init__(
23 "The following process exited with a non-zero error:\n"
24 f"=== CMD ===\n{' '.join(cmd)}\n============\n"
25 f"=== STDOUT ===\n{stdout}============\n"
26 f"=== STDERR ===\n{stderr}============\n"
27 )
30class InvalidConnectionUrlError(BaseBtrfsBackupError):
31 """Raised, if the connection url is malformed."""
34class UnknownProtocolError(InvalidConnectionUrlError):
35 """Raised, if an unsupported protocol is used."""
38class InvalidRetentionRuleError(BaseBtrfsBackupError):
39 """Raised, if the retention rule string is malformed."""
42class BtrfsSubvolumeNotFoundError(BaseBtrfsBackupError):
43 """Raised, if a BTRFS subvolume does not exist."""
46class SnapshotNotFoundError(BaseBtrfsBackupError):
47 """Raised, if a BTRFS backup snapshot does not exist."""
50class DestinationDirectoryNotFoundError(BaseBtrfsBackupError):
51 """Raised, if the destination is not found and configured to fail."""
54class BtrfsPartitionNotFoundError(BaseBtrfsBackupError):
55 """Raised, if the target location is not a valid btrfs partition."""