This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch exception type of Exception and process body request #575
Comments
mmm I'm not sure, but I don't think you can consume body in a middleware (see #394) getting the other parameters you mentioned is possible though (note that the I'd ask in Starlette if I were you
|
Yes, I saw it. But this code cannot extract body of request. Example of printing:
I cannot get body of request |
yes as I pointed out in the above linked issue #394, this is not something you can achieve in a middleware. |
A new way to handle these cases was added in #589. The docs are here: https://fastapi.tiangolo.com/tutorial/custom-request-and-route/ |
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Description
How can I catch exception type of Exception and process body request?
Additional context
My example
@app.exception_handler(Exception)
async def exception_callback(request: requests.Request, exc: Exception):
request_json = await request.json() # Here i want a body, query_params, headers and path of request
print(request_json)
@app.post('/create_workflow')
async def create_workflow():
raise Exception(13)
The text was updated successfully, but these errors were encountered: