Browse Source

fixed error handler search function to support HttpException if defined (any kind of error)

pull/2082/head
Goran Cetusic 8 years ago
parent
commit
6e1dd666b1
  1. 14
      flask/app.py

14
flask/app.py

@ -1444,14 +1444,20 @@ class Flask(_PackageBoundObject):
return handler return handler
# try blueprint handlers # try blueprint handlers
handler = find_handler(self.error_handler_spec handler_map = self.error_handler_spec.get(request.blueprint, {}).get(code)
.get(request.blueprint, {}) if handler_map is None:
.get(code)) self.error_handler_spec.get(request.blueprint, {}).get(None)
handler = find_handler(handler_map)
if handler is not None: if handler is not None:
return handler return handler
# fall back to app handlers # fall back to app handlers
return find_handler(self.error_handler_spec[None].get(code)) handler_map = self.error_handler_spec.get(request.blueprint, {}).get(None)
if handler_map is None:
self.error_handler_spec.get(None, {}).get(None)
return find_handler(handler_map)
def handle_http_exception(self, e): def handle_http_exception(self, e):
"""Handles an HTTP exception. By default this will invoke the """Handles an HTTP exception. By default this will invoke the

Loading…
Cancel
Save