Updated route documentation for aiohttp HTTP exceptions.
+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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user