Files
Foxel/middleware/exception_handler.py
2025-12-08 17:46:45 +08:00

12 lines
351 B
Python

from fastapi import Request, status
from fastapi.responses import JSONResponse
async def global_exception_handler(request: Request, exc: Exception):
"""
全局异常处理
"""
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={"error": "Internal Server Error", "detail": str(exc)},
)