flask-pydantic
flask-pydantic copied to clipboard
allow custom error responses to be generated
By defining a new config value that flask_pydantic looks for
(FLASK_PYDANTIC_VALIDATION_ERROR_RAISE), we can support raising an
exception when we have a validation error. If that is set and the
exception is raised, by default, Flask will respond with a 500 error.
However, by coupling that feature with Flask.register_error_handler
,
the user can catch the thrown exception and return whatever custom error
response the user wishes. Fixes https://github.com/bauerji/flask-pydantic/issues/45.
This is really a great change. I’ve actually been trying to work around this same issue and this would solve my needs. @bauerji could we get this reviewed and in a release?
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
@bauerji is there something else you are looking for on this?
Thank you @jcreekmore, released in version 0.11.0