Register errorhandlers for Exceptions

Allow a default errorhandler by registering
an errorhandler for HTTPException

tests included
This commit is contained in:
Florian Sachs 2017-01-08 20:42:41 +01:00 committed by cerickson
parent c8e56d5807
commit 668061a5fc
2 changed files with 34 additions and 2 deletions

View file

@ -1484,7 +1484,16 @@ class Flask(_PackageBoundObject):
return handler
# fall back to app handlers
return find_handler(self.error_handler_spec[None].get(code))
handler = find_handler(self.error_handler_spec[None].get(code))
if handler is not None:
return handler
try:
handler = find_handler(self.error_handler_spec[None][None])
except KeyError:
handler = None
return handler
def handle_http_exception(self, e):
"""Handles an HTTP exception. By default this will invoke the