feat: 中间件中打印错误栈信息
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from passlib.exc import InvalidTokenError
|
||||
@@ -70,6 +71,7 @@ def add_app_middlewares(app: FastAPI):
|
||||
return JSONResponse(content={"message": e.detail}, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
return JSONResponse(content={"message": str(e)}, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user