Skip to content

Exceptions

Missil custom exceptions.

Permission Error Exception

missil.PermissionErrorException

PermissionErrorException(status_code, detail, headers=None)

Bases: HTTPException

HTTP Exception you can raise to show on permission-related errors.

Initialize a PermissionErrorException.

PARAMETER DESCRIPTION
status_code

HTTP status code.

TYPE: int

detail

Exception description.

TYPE: str

headers

Response headers, by default {"WWW-Authenticate": "Bearer"}

TYPE: _type_ DEFAULT: None

Source code in missil/exceptions.py
def __init__(
    self,
    status_code: int,
    detail: str,
    headers: dict[str, str] | None = None,
) -> None:
    """
    Initialize a PermissionErrorException.

    Parameters
    ----------
    status_code : int
        HTTP status code.
    detail : str
        Exception description.
    headers : _type_, optional
        Response headers, by default {"WWW-Authenticate": "Bearer"}
    """
    if headers is None:
        headers = {"WWW-Authenticate": "Bearer"}

    super().__init__(status_code=status_code, detail=detail, headers=headers)

Token Error Exception

missil.TokenErrorException

TokenErrorException(status_code, detail, headers=None)

Bases: HTTPException

HTTP Exception you can raise to show on JWT token-related errors.

Initialize a TokenErrorException.

PARAMETER DESCRIPTION
status_code

HTTP status code.

TYPE: int

detail

Exception description.

TYPE: str

headers

Response headers, by default {"WWW-Authenticate": "Bearer"}

TYPE: _type_ DEFAULT: None

Source code in missil/exceptions.py
def __init__(
    self,
    status_code: int,
    detail: str,
    headers: dict[str, str] | None = None,
) -> None:
    """
    Initialize a TokenErrorException.

    Parameters
    ----------
    status_code : int
        HTTP status code.
    detail : str
        Exception description.
    headers : _type_, optional
        Response headers, by default {"WWW-Authenticate": "Bearer"}
    """
    if headers is None:
        headers = {"WWW-Authenticate": "Bearer"}

    super().__init__(status_code=status_code, detail=detail, headers=headers)