# fastapi.exceptions.HTTPException: 404 Not Found

- **ID:** `python/fastapi-http-exception-handler`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

请求的 URL 路径不存在或未定义路由。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   @app.exception_handler(404)
async def not_found_handler(request, exc):
    return JSONResponse(status_code=404, content={'message': 'Not Found'})
   ```

## Dead Ends

- **** — 会隐藏真正的 404 错误，导致客户端困惑 (70% fail)
- **** — 会拦截所有请求，导致其他路由失效 (90% fail)
