异常与异常处理¶
- exception litestar.exceptions.ClientException¶
-
Client error.
- exception litestar.exceptions.DTOFactoryException¶
-
Base DTO exception type.
- exception litestar.exceptions.HTTPException¶
-
Base exception for HTTP error responses.
These exceptions carry information to construct an HTTP response.
- 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.InvalidAnnotationException¶
-
Unexpected DTO type argument.
- 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.TooManyRequestsException¶
-
Request limits have been exceeded.
- 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¶
基类:
object表示异常响应的内容。
- litestar.exceptions.responses.create_debug_response(request: Request, exc: Exception) Response¶
从异常创建调试响应。 Args: request: 触发异常的请求。 exc: 一个异常。 Returns: Response: 根据异常详情构建的调试响应。
- litestar.exceptions.responses.create_exception_response(request: Request[Any, Any, Any], exc: Exception) Response¶
从异常构建响应。 Notes: - 对于
HTTPException的实例或其他具有status_code属性(例如 Starlette 异常)的异常类,状态码从异常中获取,否则响应状态为HTTP_500_INTERNAL_SERVER_ERROR。 Args: request: 触发异常的请求。 exc: 一个异常。 Returns: Response: 根据异常详情构建的 HTTP 响应。