参数校验错误处理 :param _: :param exc: :return:
(_: Request, exc: Union[RequestValidationError, ValidationError],)
| 120 | |
| 121 | |
| 122 | async def http422_error_handler(_: Request, exc: Union[RequestValidationError, ValidationError],) -> JSONResponse: |
| 123 | """ |
| 124 | 参数校验错误处理 |
| 125 | :param _: |
| 126 | :param exc: |
| 127 | :return: |
| 128 | """ |
| 129 | print("[422]", exc.errors()) |
| 130 | return JSONResponse( |
| 131 | { |
| 132 | "code": status.HTTP_422_UNPROCESSABLE_ENTITY, |
| 133 | "message": f"数据校验错误 {exc.errors()}", |
| 134 | "data": exc.errors(), |
| 135 | }, |
| 136 | status_code=422, |
| 137 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected