-
Notifications
You must be signed in to change notification settings - Fork 338
Allow Error Handler to Return HttpResponse #458
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
Comments
Created PR #459 |
The only way to do this is at present is by doing the following which is not ideal at all and it does not allow overriding of
|
I have also run into this issue recently and have been unable to render an HTML response when unexpected application errors are encountered. This is unfortunate, as there are parts of my API where I would like to be able to render a nice, human-readable error message with e.g., links embedded to help documentation. As currently designed, I am forced to return a json response when using |
I've found a hack workaround that works for my use-case, but it feels unnecessary, confusing, and prone to breakage. It relies on catching errors at the flask-restx layer (
Although this appears to work with my production configuration, I am reluctant to put it into prod. |
I would like to have full control of the response from error handlers assigned using
@api.errorhandler
decorator so I can obfuscate the return of calls for some usecases.For example:
However, the code assumes full control of the response assuming that a dict is returned.
The change is quite simple. In Api.py after
result = handler(e)
:The text was updated successfully, but these errors were encountered: