exceptions¶
- exception litestar.exceptions.ClientException¶
Bases:
HTTPException
Client error.
- exception litestar.exceptions.DTOFactoryException¶
Bases:
LitestarException
Base DTO exception type.
- exception litestar.exceptions.HTTPException¶
Bases:
LitestarException
Base 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 ¶
Initialize
HTTPException
.Set
detail
andargs
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. Defaults to the class’s
headers
if not provided. Set toNone
explicitly to unset the default.extra¶ – An extra mapping to attach to the exception. Defaults to the class’s
extra
if not provided. Set toNone
explicitly to unset the default.
- exception litestar.exceptions.ImproperlyConfiguredException¶
Bases:
HTTPException
,ValueError
Application has improper configuration.
- exception litestar.exceptions.InternalServerException¶
Bases:
HTTPException
Server encountered an unexpected condition that prevented it from fulfilling the request.
- exception litestar.exceptions.InvalidAnnotationException¶
Bases:
DTOFactoryException
Unexpected DTO type argument.
- exception litestar.exceptions.LitestarException¶
Bases:
Exception
Base exception class from which all Litestar exceptions inherit.
- exception litestar.exceptions.LitestarWarning¶
Bases:
UserWarning
Base class for Litestar warnings
- exception litestar.exceptions.MethodNotAllowedException¶
Bases:
ClientException
Server knows the request method, but the target resource doesn’t support this method.
- exception litestar.exceptions.MissingDependencyException¶
Bases:
LitestarException
,ImportError
Missing optional dependency.
This exception is raised only when a module depends on a dependency that has not been installed.
- exception litestar.exceptions.NoRouteMatchFoundException¶
Bases:
InternalServerException
A route with the given name could not be found.
- exception litestar.exceptions.NotAuthorizedException¶
Bases:
ClientException
Request lacks valid authentication credentials for the requested resource.
- exception litestar.exceptions.NotFoundException¶
Bases:
ClientException
,ValueError
Cannot find the requested resource.
- exception litestar.exceptions.PermissionDeniedException¶
Bases:
ClientException
Request understood, but not authorized.
- exception litestar.exceptions.SerializationException¶
Bases:
LitestarException
Encoding or decoding of an object failed.
Bases:
InternalServerException
Server is not ready to handle the request.
Exception status code.
- exception litestar.exceptions.TemplateNotFoundException¶
Bases:
InternalServerException
Referenced template could not be found.
- exception litestar.exceptions.TooManyRequestsException¶
Bases:
ClientException
Request limits have been exceeded.
- exception litestar.exceptions.ValidationException¶
Bases:
ClientException
,ValueError
Client data validation error.
- exception litestar.exceptions.WebSocketDisconnect¶
Bases:
WebSocketException
Exception class for websocket disconnect events.
- exception litestar.exceptions.WebSocketException¶
Bases:
LitestarException
Exception class for websocket related events.
- class litestar.exceptions.responses.ExceptionResponseContent¶
Bases:
object
Represent the contents of an exception-response.
- litestar.exceptions.responses.create_debug_response(request: Request, exc: Exception) Response ¶
Create a debug response from an exception.
- litestar.exceptions.responses.create_exception_response(request: Request[Any, Any, Any], exc: Exception) Response ¶
Construct a response from an exception.
Notes
For instances of
HTTPException
or other exception classes that have astatus_code
attribute (e.g. Starlette exceptions), the status code is drawn from the exception, otherwise response status isHTTP_500_INTERNAL_SERVER_ERROR
.