Skip to content

Exceptions

Exceptions raised by the Barbara SDK.

BarbaraApiError

BarbaraApiError(
    message: str,
    *,
    status: Optional[int] = None,
    body: Any = None,
)

Bases: RuntimeError

Base error for any non-2xx response from the Barbara API.

body is the server's raw error response (parsed JSON if the response was JSON, otherwise raw text) — never the request you sent, so it can't contain your credentials. It CAN still contain data about the resource you were operating on (e.g. a validation error echoing back a field value). Avoid logging exc.body indiscriminately in a context you don't control — log str(exc)/exc.status instead unless you specifically need the body for debugging.

BarbaraAuthError

BarbaraAuthError(
    message: str,
    *,
    status: Optional[int] = None,
    body: Any = None,
)

Bases: BarbaraApiError

Raised when authentication (token request or refresh) fails.

BarbaraNotFoundError

BarbaraNotFoundError(
    message: str,
    *,
    status: Optional[int] = None,
    body: Any = None,
)

Bases: BarbaraApiError

Raised on a 404, or when a lookup by name (e.g. deviceName) has no match.

BarbaraPermissionError

BarbaraPermissionError(
    message: str,
    *,
    status: Optional[int] = None,
    body: Any = None,
)

Bases: BarbaraApiError

Raised on a 401/403 for a required (non-optional) resource.