From 04ac845e5b19d35c41800835ede60e03a7bc9cc6 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Fri, 7 Feb 2025 20:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=BC=82=E5=B8=B8=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=99=A8=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81=20(#49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/common/exception/exception_handler.py | 7 ------- backend/common/security/jwt.py | 1 - 2 files changed, 8 deletions(-) diff --git a/backend/common/exception/exception_handler.py b/backend/common/exception/exception_handler.py index 1dbd247..77c209d 100644 --- a/backend/common/exception/exception_handler.py +++ b/backend/common/exception/exception_handler.py @@ -77,7 +77,6 @@ async def _validation_exception_handler(request: Request, e: RequestValidationEr 'msg': msg, 'data': data, } - request.state.__request_validation_exception__ = content # 用于在中间件中获取异常信息 return MsgSpecJSONResponse(status_code=422, content=content) @@ -100,7 +99,6 @@ async def http_exception_handler(request: Request, exc: HTTPException): else: res = response_base.fail(res=CustomResponseCode.HTTP_400) content = res.model_dump() - request.state.__request_http_exception__ = content return MsgSpecJSONResponse( status_code=_get_exception_code(exc.status_code), content=content, @@ -143,7 +141,6 @@ async def pydantic_user_error_handler(request: Request, exc: PydanticUserError): 'msg': CUSTOM_USAGE_ERROR_MESSAGES.get(exc.code), 'data': None, } - request.state.__request_pydantic_user_error__ = content return MsgSpecJSONResponse( status_code=StandardResponseCode.HTTP_500, content=content, @@ -167,7 +164,6 @@ async def assertion_error_handler(request: Request, exc: AssertionError): else: res = response_base.fail(res=CustomResponseCode.HTTP_500) content = res.model_dump() - request.state.__request_assertion_error__ = content return MsgSpecJSONResponse( status_code=StandardResponseCode.HTTP_500, content=content, @@ -187,7 +183,6 @@ async def custom_exception_handler(request: Request, exc: BaseExceptionMixin): 'msg': str(exc.msg), 'data': exc.data if exc.data else None, } - request.state.__request_custom_exception__ = content return MsgSpecJSONResponse( status_code=_get_exception_code(exc.code), content=content, @@ -212,7 +207,6 @@ async def all_unknown_exception_handler(request: Request, exc: Exception): else: res = response_base.fail(res=CustomResponseCode.HTTP_500) content = res.model_dump() - request.state.__request_all_unknown_exception__ = content return MsgSpecJSONResponse( status_code=StandardResponseCode.HTTP_500, content=content, @@ -248,7 +242,6 @@ async def cors_custom_code_500_exception_handler(request, exc): else: res = response_base.fail(res=CustomResponseCode.HTTP_500) content = res.model_dump() - request.state.__request_cors_500_exception__ = content response = MsgSpecJSONResponse( status_code=exc.code if isinstance(exc, BaseExceptionMixin) else StandardResponseCode.HTTP_500, content=content, diff --git a/backend/common/security/jwt.py b/backend/common/security/jwt.py index 44c0237..58f5ad7 100644 --- a/backend/common/security/jwt.py +++ b/backend/common/security/jwt.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- - from fastapi import Depends, Request from fastapi.security import OAuth2PasswordBearer from fastapi.security.utils import get_authorization_scheme_param