# AttributeError: 'HTTPException' object has no attribute 'detail'

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

## Root Cause

自定义异常处理器中错误地访问了 `exc.detail`，但该属性不存在或名称错误。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   在异常处理器中使用 `exc.detail` 获取错误信息，如 `return JSONResponse(status_code=exc.status_code, content={"detail": exc.detail})`。
   ```
2. **** (90% success)
   ```
   确保导入 `from fastapi import HTTPException` 并使用正确的属性。
   ```

## Dead Ends

- **** — 尝试使用 `exc.message` 但实际属性为 `detail`，导致 AttributeError。 (70% fail)
- **** — 在异常处理器中未正确导入 HTTPException，导致类型不匹配。 (50% fail)
