Custom error handling for logging the errors to the TinyAgent log file.
(request, exc)
| 50 | |
| 51 | @app.exception_handler(StarletteHTTPException) |
| 52 | async def custom_http_exception_handler(request, exc): |
| 53 | """ |
| 54 | Custom error handling for logging the errors to the TinyAgent log file. |
| 55 | """ |
| 56 | log(f"HTTPException {exc.status_code}: {exc.detail}") |
| 57 | return PlainTextResponse(exc.detail, status_code=exc.status_code) |
| 58 | |
| 59 | |
| 60 | @app.post("/generate") |