Skip to content

Exceptions

CombadgeError

Base error for any Combadge error.

Source code in combadge/core/errors.py
class CombadgeError(Exception):
    """Base error for any Combadge error."""

BackendError

Base error for any backend errors.

Examples:

Handling inner error:

>>> try:
>>>     client.method()
>>> except BackendError as e:
>>>     match e.inner:
>>>         case httpx.TimeoutException():
>>>             # Handle timeout error.
>>>         case _:
>>>             raise

Wrapping client call (only needed for a new backend implementation):

>>> with BackendError:
>>>     ...
Source code in combadge/core/errors.py
class BackendError(CombadgeError, metaclass=_BackendErrorMeta):
    """
    Base error for any backend errors.

    Examples:
        Handling inner error:

        >>> try:
        >>>     client.method()
        >>> except BackendError as e:
        >>>     match e.inner:
        >>>         case httpx.TimeoutException():
        >>>             # Handle timeout error.
        >>>         case _:
        >>>             raise

        Wrapping client call (only needed for a new backend implementation):

        >>> with BackendError:
        >>>     ...
    """

    def __init__(self, inner: BaseException) -> None:
        """
        Instantiate the backend error.

        Args:
            inner: wrapped backend client exception
        """
        super().__init__(inner)

    @property
    def inner(self) -> BaseException:
        """Get the wrapped backend client exception."""
        return self.args[0]

inner property

inner: BaseException

Get the wrapped backend client exception.

__init__

__init__(inner: BaseException) -> None

Instantiate the backend error.

Parameters:

Name Type Description Default
inner BaseException

wrapped backend client exception

required
Source code in combadge/core/errors.py
def __init__(self, inner: BaseException) -> None:
    """
    Instantiate the backend error.

    Args:
        inner: wrapped backend client exception
    """
    super().__init__(inner)