python
runtime_error
ai_generated
true
starlette.exceptions.HTTPException: 500 Internal Server Error
ID: python/starlette-http-exception-handling
80%Fix Rate
86%Confidence
0Evidence
2025-01-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
服务器内部发生未捕获的异常,导致 500 错误。
generic中文
服务器内部发生未捕获的异常,导致 500 错误。
Workarounds
-
95% success
@app.exception_handler(Exception) async def exception_handler(request, exc): return JSONResponse(status_code=500, content={'message': 'Internal Server Error'})
Dead Ends
Common approaches that don't work:
-
80% fail
会掩盖真实错误,导致调试困难
-
90% fail
会导致状态不一致,且可能崩溃