Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the global exception log stack #406

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/middleware/jwt_auth_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def authenticate(self, request: Request) -> tuple[AuthCredentials, Current
except TokenError as exc:
raise _AuthenticationError(code=exc.code, msg=exc.detail, headers=exc.headers)
except Exception as e:
log.exception(e)
log.error(f'JWT 授权异常:{e}')
raise _AuthenticationError(code=getattr(e, 'code', 500), msg=getattr(e, 'msg', 'Internal Server Error'))

# 请注意,此返回使用非标准模式,所以在认证通过时,将丢失某些标准特性
Expand Down
2 changes: 1 addition & 1 deletion backend/middleware/opera_log_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def execute_request(self, request: Request, call_next) -> RequestCallNext:
response = await call_next(request)
code, msg = self.validation_exception_handler(request, code, msg)
except Exception as e:
log.exception(e)
log.error(f'请求异常: {e}')
# code 处理包含 SQLAlchemy 和 Pydantic
code = getattr(e, 'code', None) or code
msg = getattr(e, 'msg', None) or msg
Expand Down