Skip to content
Discussion options

You must be logged in to vote

The simplest way is to add a try/except at the location that the error can occur, and raise a Problem with the details you would like.

The title is the more appropriate location for the generic message you would like, as the details gives a little context as to how the server failed. To change the title of all unhandled server errors change the ServerError title in that example file.

The other way if you have a lot of locations where this error can occur is to use a custom handler for the error type and convert the error to a Problem with the details you would like.

https://nrwldev.github.io/fastapi-problem/handlers/

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@EdgyEdgemond
Comment options

Answer selected by dineshbvadhia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants