Skip to content

Commit

Permalink
Merge 5d22e5c into d42641a
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Oct 1, 2018
2 parents d42641a + 5d22e5c commit 8ed5a50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions flask_rest_api/error_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Exception handler"""

from werkzeug.exceptions import (
default_exceptions, HTTPException, InternalServerError)
from werkzeug.exceptions import HTTPException, InternalServerError
from flask import jsonify, current_app


Expand All @@ -11,15 +10,10 @@ class ErrorHandlerMixin:
def _register_error_handlers(self):
"""Register error handlers in Flask app
This method registers an error handler for every exception code.
This method registers a default error handler for HTTPException.
"""
# On Flask versions older than 1.0, it is not possible to register a
# handler for all HTTPException at once, so we register the handler
# for each code explicitly.
# https://github.com/pallets/flask/issues/941#issuecomment-118975275
# This workaround can be dropped when dropping Flask<1.0 compatibility.
for code in default_exceptions:
self._app.register_error_handler(code, self.handle_http_exception)
self._app.register_error_handler(
HTTPException, self.handle_http_exception)

def handle_http_exception(self, error):
"""Return error description and details in response body
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
install_requires=[
'werkzeug>=0.11',
'flask>=0.11',
'flask>=1.0',
'marshmallow>=2.15.2',
'webargs>=1.5.2',
'apispec>=0.39.0',
Expand Down

0 comments on commit 8ed5a50

Please sign in to comment.