Integration with flask-restful & error handling
See original GitHub issueSimilar to #86, errors like SignatureExpiry are returning 500 rather than 4xx errors.
However I am using flask-restful which does not have an error_handler, so the solutions in the referenced issue do not apply.
Flask-restful is briefly mentioned on the releases page here , but setting application.config['PROPAGATE_EXCEPTIONS'] = True
didn’t have any effect for me.
Any insight into how I can correctly deal with error handling using flask-restful?
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
python - Flask-restful - Custom error handling - Stack Overflow
Flask -RESTful will call the handle_error() function on any 400 or 500 error that happens on a Flask-RESTful route, and leave other routes...
Read more >Handling Application Errors — Flask Documentation (2.2.x)
When an error occurs in Flask, an appropriate HTTP status code will be returned. 400-499 indicate errors with the client's request data, or...
Read more >How To Handle Errors in a Flask Application - DigitalOcean
Step 1 — Using The Flask Debugger · Step 2 — Creating Custom Error Pages · Step 3 — Using Logging to Track...
Read more >Flask Rest API -Part:4- Exception Handling
So, to solve such issues we are going to use Exception Handling to catch such exceptions and send a proper error message to...
Read more >Developing RESTful APIs with Python and Flask - Auth0
We'll update the code soon with latest versions of Flask and Python. To answer this again the error you encountered was because of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
I also encountered this issue. I could not replicate it at all in development, but was getting 500s instead of 401s in production and staging.
I was able to reproduce it by setting the debug setting to false in development mode, and the 500s showed up.
I was able to fix it by setting
application.config['PROPAGATE_EXCEPTIONS'] = True
@paurakhsharma
I think I found a workaround to integrate custom errors. Here’s my current setup: Set
PROPAGATE_EXCEPTIONS = False
Then overwrite the error handlerflask_restful.Api
object as such:This way, flask_restful’s errors are handled by flask_restful’s Api object, and other errors fall through to Flask’s error handler.