marshmallow-code / flask-smorest

DB agnostic framework to build auto-documented REST APIs with Flask and marshmallow
https://flask-smorest.readthedocs.io
MIT License
634 stars 72 forks source link

Improve errorhandler #644

Open TGoddessana opened 2 months ago

TGoddessana commented 2 months ago

There are a few issues... (shouldn't be merged yet)

  1. The abort(code) works, but raise ApiException() doesn't work with the json response, in my opinion, raising an ApiException should automatically result in a 500 json handling, but it's not. The flask_abort() and api_abort() use cases work anyway... I just want to handle them elegantly. (What should be the behavior if the user raises ApiException() instead of flask_smorest.abort()?)

  2. I looked at the method you mentioned in the original issue(re-define all werkzeug exceptions), and my guess is that since we are inheriting and defining some exceptions from Flask-Smorest, it would be better to explicitly inherit them all, even if it makes the code a bit longer (I'd love to hear your opinion).