INNER CODE UNIT · Python
unhandled_exception_handler
yaojingang/GEORank · backend/app/main.py:334
async def unhandled_exception_handler(request: Request, exc: Exception):
"""全局异常兜底 — 不向客户端暴露内部错误详情"""
import logging
logging.getLogger("georank").error(
"Unhandled exception: %s %s", request.method, request.url.path, exc_info=exc
)
return JSONResponse(status_code=500, content={"detail": "服务器内部错误"})