# RuntimeError: 未返回响应。

- **ID:** `python/starlette-no-response-returned`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

中间件或端点返回了None而不是Response，或者异常被吞掉且未返回响应。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   async def mw(request, call_next):\n    try:\n        return await call_next(request)\n    except Exception:\n        return JSONResponse({'err': 'x'}, status_code=500)
   ```
2. **** (95% 成功率)
   ```
   @app.get('/')\nasync def r():\n    return JSONResponse({})
   ```

## 无效尝试

- **** — Swallowing exceptions leaves no response; error persists. (90% 失败率)
- **** — Raises the original error but does not produce a Response. (60% 失败率)
