I am developing REST API in flask and plan to run it in Gunicorn. In my appliction, an user-defined Exception was handled by by flask errorhandler decorator. It works fine in both flask build-in web server and Gunicorn. The respone can be generated from decorated function. After introducting flask_restful, the build-in server works fine, but in Gunicorn, the respone is always {"message": "Internal Server Error"}.
My Environments: Flask (0.10.1), Flask-RESTful (0.3.4), gunicorn (19.4.1)
I also asked on StackOverFlow but no answer. Please see the details: http://stackoverflow.com/questions/34037283/flask-errorhandler-does-not-work-in-gunicorn-after-introducing-flask-restful
error handling isn't that great at the moment, see the docs.
Improvements are in progress in #541
I have a similar problem.
My code look like this:
apiv1 = Blueprint('apiv1', __name__)
api = Api(apiv1)
@apiv1.errorhandler(CustomException)
def hander_(error):
return jsonify({}), 400
In debug mode, the flask errorhandler works fine.
But in none-debug mode, the errorhandler will not work. It never catch the CustomException.
Hi,
Is there an update on this issue? Should we open a new one? It looks like https://github.com/flask-restful/flask-restful/pull/541 got abandoned and we're having similar issues with handle_error(): it seems to work fine with the development server, but it does not seem to work when using gunicorn.
Getting a similar issue, exception handler working well in built-in WebServer, but with gunicorn, error handler not working.