-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Description
I've been using a 404 exception handler like below:
@app.exception_handler(status.HTTP_404_NOT_FOUND)
async def _(request: Request, exc: HTTPException) -> HTMLResponse:
return templates.TemplateResponse(
request=request, name="404.html", context={"...": ...}
)It'd be helpful if there was a way to use fasthx with exception handlers too, for example an exception: bool flag to .hx and .page. When converting my other routes to use fasthx, I would otherwise not reference fastapi's TemplateResponse anymore.
If you try to use fasthx for this now:
@app.exception_handler(status.HTTP_404_NOT_FOUND)
@jinja.page("404.html")
async def _(request: Request, exc: HTTPException) -> HTMLResponse:
return {"...": ...}it raises an error like below:
File "<...>/.venv/lib/python3.13/site-packages/fasthx/utils.py", line 46, in execute_maybe_sync_func
return await func(*args, **kwargs) # type: ignore[no-any-return]
~~~~^^^^^^^^^^^^^^^^^
TypeError: create_app.<locals>._() missing 1 required positional argument: 'exc'
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested