Skip to content
Open
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
28 changes: 27 additions & 1 deletion auditor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
)

# 包含路由
app.include_router(auditor_router, prefix="/api/v1/auditor")
app.include_router(auditor_router, prefix="/api/v1")

# 根路径路由
@app.get("/", tags=["系统接口"], summary="服务根路径")
Expand Down Expand Up @@ -144,6 +144,32 @@ async def health_check():
"service": "auditor"
}


# 在 auditor/main.py 中添加全局异常处理
from fastapi import Request
from fastapi.responses import JSONResponse



# 在 auditor/main.py 的全局异常处理器中添加详细日志
@app.exception_handler(Exception)
async def global_exception_handler(request: Request, exc: Exception):
"""全局异常处理器"""
import traceback
logger.error(f"全局异常: {str(exc)}")
logger.error(f"请求URL: {request.url}")
logger.error(f"请求方法: {request.method}")
logger.error(f"异常堆栈: {traceback.format_exc()}")

return JSONResponse(
status_code=500,
content={
"code": 500,
"msg": f"服务器内部错误: {str(exc)}",
"success": False,
"data": None
}
)
# 支持直接运行
if __name__ == "__main__":
import uvicorn
Expand Down
720 changes: 604 additions & 116 deletions auditor/schemas/data_schemas.py

Large diffs are not rendered by default.

Loading