Skip to content

Exceptions

The HTTP exceptions crudauth raises. All subclass CustomException, which is a FastAPI HTTPException, so they propagate with the right status code and headers.

crudauth.exceptions.CustomException

CustomException(
    status_code: int = HTTP_500_INTERNAL_SERVER_ERROR,
    detail: str | None = None,
    headers: dict[str, str] | None = None,
)

Bases: HTTPException

crudauth.exceptions.BadRequestException

BadRequestException(detail: str | None = None)

crudauth.exceptions.NotFoundException

NotFoundException(detail: str | None = None)

crudauth.exceptions.ForbiddenException

ForbiddenException(detail: str | None = None)

crudauth.exceptions.UnauthorizedException

UnauthorizedException(detail: str | None = None)

crudauth.exceptions.UnprocessableEntityException

UnprocessableEntityException(detail: str | None = None)

crudauth.exceptions.DuplicateValueException

DuplicateValueException(detail: str | None = None)

crudauth.exceptions.RateLimitException

RateLimitException(
    detail: str | None = None,
    retry_after: int | None = None,
    headers: dict[str, str] | None = None,
)

crudauth.exceptions.SudoLockoutError

SudoLockoutError(
    detail: str | None = None,
    retry_after: int | None = None,
)

Bases: CustomException

Raised when too many wrong-password sudo attempts lock re-authentication.

Distinct from RateLimitException (its own sudo:* counter, separate from login lockout) but shares the 429 + Retry-After shape.

crudauth.exceptions.CSRFException

CSRFException(detail: str = 'CSRF token validation failed')

Bases: CustomException

Raised when CSRF validation fails on an unsafe (mutating) request.