# werkzeug.exceptions.NotFound: 404 未找到

- **ID:** `python/flask-abort-http-exception`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

调用了 abort(404) 函数，但未正确设置错误处理器来返回自定义响应。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Register an error handler: @app.errorhandler(404) def not_found(e): return jsonify(error='Not Found'), 404
   ```
2. **** (90% 成功率)
   ```
   Use abort(404, description="Custom message") and handle it in the handler.
   ```

## 无效尝试

- **** — This masks the error and gives incorrect status codes. (80% 失败率)
- **** — This is not suitable for APIs that need JSON responses. (70% 失败率)
