Skip to content

Commit

Permalink
清理异常拦截器冗余代码 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan authored Feb 7, 2025
1 parent 92df527 commit 04ac845
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
7 changes: 0 additions & 7 deletions backend/common/exception/exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion backend/common/security/jwt.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 04ac845

Please sign in to comment.