-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch-all errorhandler does not catch BadRequestKeyError #2268
Comments
werkzeug.exceptions.BadRequestKeyError
Closing since this has the same issue: #2267. We have a handler in another project for |
Does enabling the |
@ThiefMaster no, still same issue |
Actually, turns out the issue is with other |
This is more similar to #941. This issue here is that |
Is there still a way now to catch all HTTPExceptions? I believe that this is a good feature as we might use third party libraries and it is not always clear what kind of exceptions are thrown by the third party library. |
You can catch standard
This will work for most real-life cases. However, there are several bugs/caveats:
You can change http exception handling by setting the
|
@ngaya-ll Hi, thanks for your quick reply! I tried the code that you suggested, however it does not take any effect. But I am using flask-restplus on top of flask, could it be that they have some conflicts? |
I'm not familiar with flask-restplus but from the documentation it appears that that extension modifies the error handling behavior, so my above comment may not apply. |
Fixed by #2314. |
Versions
Python 3.6.1
Flask 0.12.1
Werkzeug 0.12.1
Issue
A catch-all error handler (one that catches
Exception
), does not catchwerkzeug.exceptions.BadRequestKeyError
. Here's a very quick illustration of the issue:https://github.com/sampeka/flask-issue
Steps to repoduce:
python ./example.py
/good
, see that the error handler is correctly called/bad
, see that the error handler is not calledIf I define an error handler specifically for
BadRequestKeyError
it will be called, as expected.Edit: If you downgrade to
Flask==0.10.1
, this example will work.The text was updated successfully, but these errors were encountered: