try/except and fastapi-problem #9
-
|
My fastapi code is littered with try/except clauses to capture exceptions eg. Does using fastapi-problem's |
Beta Was this translation helpful? Give feedback.
Answered by
EdgyEdgemond
May 20, 2024
Replies: 1 comment 4 replies
-
|
If an exception is raised, and you would like to do something specific, you can try/except/do something. if you just want to convert the error into a response for the user you can let the exception raise, this will trigger a 500 error response if its not an internally raised Problem subclass. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure i understand the question here, if you want to capture and log unexpected errors, this already occurs in the exception handler.
If you are catching errors and raising different errors you can use
raise Exception from eformat to maintain the exception chain, this is standard python syntax, not related to fastapi-problem specifically.