MCPcopy Create free account
hub / github.com/binkuolo/fastapi / http422_error_handler

Function http422_error_handler

core/Exception.py:122–137  ·  view source on GitHub ↗

参数校验错误处理 :param _: :param exc: :return:

(_: Request, exc: Union[RequestValidationError, ValidationError],)

Source from the content-addressed store, hash-verified

120
121
122async 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 )

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected