Updated route documentation for aiohttp HTTP exceptions.

2026-04-27 15:34:27 -04:00
parent b4e73c6f16
commit d8cc18d242
+3 -1
@@ -147,6 +147,8 @@ Route handlers support four return types:
| `web.FileResponse` | Serves a file from disk. Sets content type, length, and caching headers automatically. |
| `None` | Returns a `204 No Content` response. |
For redirects or explicit HTTP status responses, raise an `aiohttp.web.HTTPException` subclass such as `web.HTTPFound`, `web.HTTPSeeOther`, `web.HTTPForbidden`, or `web.HTTPNotFound`.
```python
from pathlib import Path
@@ -178,7 +180,7 @@ async def incoming_webhook(ctx: RouteContext) -> None:
## Error Handling
If a route handler raises an exception, the error is logged and the client receives an empty `500` response. The same applies if the handler exceeds the configured `handler_timeout` (default 30 seconds); it is cancelled and the client receives a `500`. Streaming handlers (`streaming=True`) are exempt from the timeout.
Raised `aiohttp.web.HTTPException` values are passed through unchanged. Use them for redirects and explicit HTTP error responses. Other uncaught exceptions are logged and the client receives an empty `500` response. The same applies if the handler exceeds the configured `handler_timeout` (default 30 seconds); it is cancelled and the client receives a `500`. Streaming handlers (`streaming=True`) are exempt from the timeout.
## URL Building