exceptions¶
- exception litestar.exceptions.ClientException[source]¶
Bases:
HTTPExceptionClient error.
- exception litestar.exceptions.DTOFactoryException[source]¶
Bases:
LitestarExceptionBase DTO exception type.
- exception litestar.exceptions.HTTPException[source]¶
Bases:
LitestarExceptionBase exception for HTTP error responses.
These exceptions carry information to construct an HTTP response.
- __init__(*args: Any, detail: str = '', status_code: int | None = None, headers: dict[str, str] | None | Literal[_EmptyEnum.EMPTY] = _EmptyEnum.EMPTY, extra: dict[str, Any] | list[Any] | None | Literal[_EmptyEnum.EMPTY] = _EmptyEnum.EMPTY) None[source]¶
Initialize
HTTPException.Set
detailandargsif not provided.- Parameters:
*args¶ – if
detailkwarg 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. Defaults to the class’s
headersif not provided. Set toNoneexplicitly to unset the default.extra¶ – An extra mapping to attach to the exception. Defaults to the class’s
extraif not provided. Set toNoneexplicitly to unset the default.
- exception litestar.exceptions.ImproperlyConfiguredException[source]¶
Bases:
HTTPException,ValueErrorApplication has improper configuration.
- exception litestar.exceptions.InternalServerException[source]¶
Bases:
HTTPExceptionServer encountered an unexpected condition that prevented it from fulfilling the request.
- exception litestar.exceptions.InvalidAnnotationException[source]¶
Bases:
DTOFactoryExceptionUnexpected DTO type argument.
- exception litestar.exceptions.LitestarException[source]¶
Bases:
ExceptionBase exception class from which all Litestar exceptions inherit.
- exception litestar.exceptions.LitestarWarning[source]¶
Bases:
UserWarningBase class for Litestar warnings
- exception litestar.exceptions.MethodNotAllowedException[source]¶
Bases:
ClientExceptionServer knows the request method, but the target resource doesn’t support this method.
- exception litestar.exceptions.MissingDependencyException[source]¶
Bases:
LitestarException,ImportErrorMissing optional dependency.
This exception is raised only when a module depends on a dependency that has not been installed.
- exception litestar.exceptions.NoRouteMatchFoundException[source]¶
Bases:
InternalServerExceptionA route with the given name could not be found.
- exception litestar.exceptions.NotAuthorizedException[source]¶
Bases:
ClientExceptionRequest lacks valid authentication credentials for the requested resource.
- exception litestar.exceptions.NotFoundException[source]¶
Bases:
ClientException,ValueErrorCannot find the requested resource.
- exception litestar.exceptions.PermissionDeniedException[source]¶
Bases:
ClientExceptionRequest understood, but not authorized.
- exception litestar.exceptions.SerializationException[source]¶
Bases:
LitestarExceptionEncoding or decoding of an object failed.
Bases:
InternalServerExceptionServer is not ready to handle the request.
Exception status code.
- exception litestar.exceptions.TemplateNotFoundException[source]¶
Bases:
InternalServerExceptionReferenced template could not be found.
- exception litestar.exceptions.TooManyRequestsException[source]¶
Bases:
ClientExceptionRequest limits have been exceeded.
- exception litestar.exceptions.ValidationException[source]¶
Bases:
ClientException,ValueErrorClient data validation error.
- exception litestar.exceptions.WebSocketDisconnect[source]¶
Bases:
WebSocketExceptionException class for websocket disconnect events.
- exception litestar.exceptions.WebSocketException[source]¶
Bases:
LitestarExceptionException class for websocket related events.
- class litestar.exceptions.responses.ExceptionResponseContent[source]¶
Bases:
objectRepresent the contents of an exception-response.
- litestar.exceptions.responses.create_debug_response(request: Request, exc: Exception) Response[source]¶
Create a debug response from an exception.
- litestar.exceptions.responses.create_exception_response(request: Request[Any, Any, Any], exc: Exception) Response[source]¶
Construct a response from an exception.
Notes
For instances of
HTTPExceptionor other exception classes that have astatus_codeattribute (e.g. Starlette exceptions), the status code is drawn from the exception, otherwise response status isHTTP_500_INTERNAL_SERVER_ERROR.