exceptions¶
- exception litestar.exceptions.HTTPException[源代码]¶
-
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
detailandargsif not provided.- 参数:
*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[源代码]¶
-
Application has improper configuration.
- exception litestar.exceptions.InternalServerException[源代码]¶
-
Server encountered an unexpected condition that prevented it from fulfilling the request.
- exception litestar.exceptions.LitestarException[源代码]¶
基类:
ExceptionBase exception class from which all Litestar exceptions inherit.
- exception litestar.exceptions.LitestarWarning[源代码]¶
基类:
UserWarningBase class for Litestar warnings
- exception litestar.exceptions.MethodNotAllowedException[源代码]¶
-
Server knows the request method, but the target resource doesn't support this method.
- exception litestar.exceptions.MissingDependencyException[源代码]¶
基类:
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[源代码]¶
-
A route with the given name could not be found.
- exception litestar.exceptions.NotAuthorizedException[源代码]¶
-
Request lacks valid authentication credentials for the requested resource.
- exception litestar.exceptions.NotFoundException[源代码]¶
基类:
ClientException,ValueErrorCannot find the requested resource.
- exception litestar.exceptions.PermissionDeniedException[源代码]¶
-
Request understood, but not authorized.
- exception litestar.exceptions.SerializationException[源代码]¶
-
Encoding or decoding of an object failed.
-
Server is not ready to handle the request.
Exception status code.
- exception litestar.exceptions.TemplateNotFoundException[源代码]¶
-
Referenced template could not be found.
- exception litestar.exceptions.ValidationException[源代码]¶
基类:
ClientException,ValueErrorClient data validation error.
- exception litestar.exceptions.WebSocketDisconnect[源代码]¶
-
Exception class for websocket disconnect events.
- exception litestar.exceptions.WebSocketException[源代码]¶
-
Exception class for websocket related events.
- class litestar.exceptions.responses.ExceptionResponseContent[源代码]¶
基类:
objectRepresent 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.
备注
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.