Skip to content

Exceptions

SystemdClientError

systemd_client.exceptions.SystemdClientError

Bases: Exception

Base exception for all systemd-client errors.

Source code in src/systemd_client/exceptions.py
class SystemdClientError(Exception):
    """Base exception for all systemd-client errors."""

UnitNotFoundError

systemd_client.exceptions.UnitNotFoundError

Bases: SystemdClientError

Raised when a unit is not found.

Source code in src/systemd_client/exceptions.py
class UnitNotFoundError(SystemdClientError):
    """Raised when a unit is not found."""

    def __init__(self, unit_name: str) -> None:
        self.unit_name = unit_name
        super().__init__(f"Unit not found: {unit_name}")

UnitOperationError

systemd_client.exceptions.UnitOperationError

Bases: SystemdClientError

Raised when a unit operation fails.

Source code in src/systemd_client/exceptions.py
class UnitOperationError(SystemdClientError):
    """Raised when a unit operation fails."""

    def __init__(self, unit_name: str, operation: str, detail: str) -> None:
        self.unit_name = unit_name
        self.operation = operation
        self.detail = detail
        super().__init__(f"Failed to {operation} {unit_name}: {detail}")

BackendError

systemd_client.exceptions.BackendError

Bases: SystemdClientError

Base exception for backend-related errors.

Source code in src/systemd_client/exceptions.py
class BackendError(SystemdClientError):
    """Base exception for backend-related errors."""

BackendNotAvailableError

systemd_client.exceptions.BackendNotAvailableError

Bases: BackendError

Raised when a requested backend is not available.

Source code in src/systemd_client/exceptions.py
class BackendNotAvailableError(BackendError):
    """Raised when a requested backend is not available."""

    def __init__(self, backend: str, reason: str) -> None:
        self.backend = backend
        self.reason = reason
        super().__init__(f"Backend '{backend}' not available: {reason}")

SubprocessError

systemd_client.exceptions.SubprocessError

Bases: BackendError

Raised when a subprocess command fails unexpectedly.

Source code in src/systemd_client/exceptions.py
class SubprocessError(BackendError):
    """Raised when a subprocess command fails unexpectedly."""

    def __init__(self, command: list[str], returncode: int, stderr: str) -> None:
        self.command = command
        self.returncode = returncode
        self.stderr = stderr
        super().__init__(
            f"Command {' '.join(command)!r} failed with exit code {returncode}: {stderr}"
        )

JournalError

systemd_client.exceptions.JournalError

Bases: SystemdClientError

Base exception for journal-related errors.

Source code in src/systemd_client/exceptions.py
class JournalError(SystemdClientError):
    """Base exception for journal-related errors."""

JournalParseError

systemd_client.exceptions.JournalParseError

Bases: JournalError

Raised when journal output cannot be parsed.

Source code in src/systemd_client/exceptions.py
class JournalParseError(JournalError):
    """Raised when journal output cannot be parsed."""

    def __init__(self, detail: str = "") -> None:
        self.detail = detail
        super().__init__(f"Failed to parse journal output: {detail}" if detail else
                         "Failed to parse journal output")