Skip to content

Exceptions

Contains all custom exceptions used in this program.

BaseBtrfsBackupError

Bases: Exception

Base of all custom exceptions.

BtrfsPartitionNotFoundError

Bases: BaseBtrfsBackupError

Raised, if the target location is not a valid btrfs partition.

BtrfsSubvolumeNotFoundError

Bases: BaseBtrfsBackupError

Raised, if a BTRFS subvolume does not exist.

DestinationDirectoryNotFoundError

Bases: BaseBtrfsBackupError

Raised, if the destination is not found and configured to fail.

FailedProcessError

FailedProcessError(cmd, stdout='', stderr='')

Bases: BaseBtrfsBackupError

Raised, if a process returns a non-zero return code.

Parameters:

Name Type Description Default
cmd list[str]

failed command.

required
stdout str

standard output of that process.

''
stderr str

standard error of that process.

''
Source code in b4_backup/exceptions.py
def __init__(self, cmd: list[str], stdout: str = "", stderr: str = ""):
    """
    Args:
        cmd: failed command.
        stdout: standard output of that process.
        stderr: standard error of that process.
    """
    self.cmd = cmd
    self.stdout = stdout
    self.stderr = stderr

    super().__init__(
        "The following process exited with a non-zero error:\n"
        f"===  CMD   ===\n{' '.join(cmd)}\n============\n"
        f"=== STDOUT ===\n{stdout}============\n"
        f"=== STDERR ===\n{stderr}============\n"
    )

InvalidConnectionUrlError

Bases: BaseBtrfsBackupError

Raised, if the connection url is malformed.

InvalidRetentionRuleError

Bases: BaseBtrfsBackupError

Raised, if the retention rule string is malformed.

SnapshotNotFoundError

Bases: BaseBtrfsBackupError

Raised, if a BTRFS backup snapshot does not exist.

UnknownProtocolError

Bases: InvalidConnectionUrlError

Raised, if an unsupported protocol is used.