Flask-restful: Is it possible to use only flask original error handler?

Created on 3 Dec 2019  路  2Comments  路  Source: flask-restful/flask-restful

Hello there,
I am developing an API server and have to design API strictly managed.
So I want to handle exceptions in the form my API usually responds, but it seems
that I cannot control the handler manually.
I have tried to mimic the classes except for the error handler but I failed because the coupling of the classes are too dense to separate.

Is there any way that I can use flask original error handler only?
I have to handle 200, 400, 401, 403, 404, 405, 429, 500 in the same form.

Most helpful comment

I am working around like this

from flask_restful import Api as _Api
class Api(_Api):
    def error_router(self, original_handler, e):
        return original_handler(e)

All 2 comments

I am working around like this

from flask_restful import Api as _Api
class Api(_Api):
    def error_router(self, original_handler, e):
        return original_handler(e)

Same here, flask-restful seems to be stopping all my exceptions from being handled in the actual Flask app.

Using app.config[鈥楶ROPAGATE_EXCEPTIONS鈥橾 = True in the main Flask app allows us to handle them.

Was this page helpful?
0 / 5 - 0 ratings