http_exceptions#

exception starlite.exceptions.http_exceptions.HTTPException#

Bases: StarLiteException

Base exception for HTTP error responses.

These exceptions carry information to construct an HTTP response.

__init__(*args: Any, detail: str = '', status_code: Optional[int] = None, headers: Optional[Dict[str, str]] = None, extra: Optional[Union[Dict[str, Any], List[Any]]] = None) None#

Initialize HTTPException.

Set detail and args if not provided.

Parameters:
  • *args – if detail kwarg not provided, first arg should be error detail.

  • detail – Exception details or message. Will default to args[0] if not provided.

  • status_code – Exception HTTP status code.

  • headers – Headers to set on the response.

  • extra – An extra mapping to attach to the exception.

status_code: int = 500#

Exception status code.

extra: Optional[Union[Dict[str, Any], List[Any]]]#

An extra mapping to attach to the exception.

detail: str#

Exception details or message.

headers: Optional[Dict[str, str]]#

Headers to attach to the response.

exception starlite.exceptions.http_exceptions.ImproperlyConfiguredException#

Bases: HTTPException, ValueError

Application has improper configuration.

exception starlite.exceptions.http_exceptions.ClientException#

Bases: HTTPException

Client error.

status_code: int = 400#

Exception status code.

exception starlite.exceptions.http_exceptions.ValidationException#

Bases: ClientException, ValueError

Client data validation error.

exception starlite.exceptions.http_exceptions.NotAuthorizedException#

Bases: ClientException

Request lacks valid authentication credentials for the requested resource.

status_code: int = 401#

Exception status code.

exception starlite.exceptions.http_exceptions.PermissionDeniedException#

Bases: ClientException

Request understood, but not authorized.

status_code: int = 403#

Exception status code.

exception starlite.exceptions.http_exceptions.NotFoundException#

Bases: ClientException, ValueError

Cannot find the requested resource.

status_code: int = 404#

Exception status code.

exception starlite.exceptions.http_exceptions.MethodNotAllowedException#

Bases: ClientException

Server knows the request method, but the target resource doesn’t support this method.

status_code: int = 405#

Exception status code.

exception starlite.exceptions.http_exceptions.TooManyRequestsException#

Bases: ClientException

Request limits have been exceeded.

status_code: int = 429#

Exception status code.

exception starlite.exceptions.http_exceptions.InternalServerException#

Bases: HTTPException

Server encountered an unexpected condition that prevented it from fulfilling the request.

status_code: int = 500#

Exception status code.

exception starlite.exceptions.http_exceptions.ServiceUnavailableException#

Bases: InternalServerException

Server is not ready to handle the request.

status_code: int = 503#

Exception status code.

exception starlite.exceptions.http_exceptions.NoRouteMatchFoundException#

Bases: InternalServerException

A route with the given name could not be found.

exception starlite.exceptions.http_exceptions.TemplateNotFoundException#

Bases: InternalServerException

Referenced template could not be found.

__init__(*args: Any, template_name: str) None#

Initialize TemplateNotFoundException.

Parameters:
  • *args (Any) – Passed through to super().__init__() - should not include detail.

  • template_name (str) – Name of template that could not be found.