Beispiel #1
0
 async def validation_exception_handler(request: Request,
                                        exc: RequestValidationError):
     logger.debug(f"参数异常\n{request.method} | URL:{request.url}\n{exc}")
     return ORJSONResponse(
         status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
         content=exc._error_cache,
     )
Beispiel #2
0
 async def http_exception_handler(request: Request, exc: HTTPException):
     logger.debug(
         f"HTTP异常\n{request.method} | URL:{request.url} | {exc.detail}")
     return ORJSONResponse(
         status_code=status.HTTP_400_BAD_REQUEST,
         content=exc.detail,
     )
Beispiel #3
0
 async def validation_exception_handler(request: Request,
                                        exc: RequestValidationError):
     logger.debug(f"参数异常\n{request.method} | URL:{request.url}\n{exc}")
     return response_code.resp_400(str(exc))
Beispiel #4
0
 async def http_exception_handler(request: Request, exc: HTTPException):
     logger.debug(
         f"HTTP异常\n{request.method} | URL:{request.url} | {exc.detail}")
     return response_code.resp_400(exc.detail)
Beispiel #5
0
 async def notfount_exception_handler(request: Request,
                                      exc: NotFoundException):
     logger.debug(
         f"无效请求\n{request.method} | URL:{request.url} | {exc.err_desc}")
     return response_code.resp_404(exc.err_desc)
Beispiel #6
0
 async def token_exception_handler(request: Request,
                                   exc: UserTokenException):
     logger.debug(
         f"认证异常\n{request.method} | URL:{request.url} | {exc.err_desc}")
     return response_code.resp_403(exc.err_desc)