Open codethief opened 6 years ago
I have this same issue, from what I can tell, it appears to have been fixed in December of 2017, however the last release (0.10.1) was in March of 2017.
I see, so it all comes down to issue #418.
Same issue with 0.12.1.
Basically, the root cause is API.error_handlers
is a dict, which means it's not ordered.
If you register an error along with its inheritance, you can't tell which comes first if you iterate API.error_handlers
.
https://github.com/noirbizarre/flask-restplus/blob/0.12.1/flask_restplus/api.py#L600 indicates only the first matched error type will be processed.
In the code example below, I'm defining a custom error handler for errors of type
BaseError
but if I raiseInsecurePasswordError
(a child class ofBaseError
), it won't be caught by said error handler and I end up with an internal server error (500). If I define the error handler forInsecurePasswordHandler
directly, though, everything works fine. (Obviously, I'd like to avoid that because I have dozens of error classes.)Output of
$ pip list | grep -i flask
:Temporary workaround: Define error handler for every single subclass of
BaseError
:(Note that this will only work for direct subclasses of
BaseError
.)