def _handle_error(self, e):
"""Returns handled excpetion. Detects blueprint from global
:class:`~flask.wrappers.Request` object, and passes exception object to
its `registered_errorhandler`.
"""
blueprint = self._detect_blueprint()
if isinstance(e, HTTPException):
if self._error_loader_callback is not None:
e = self._error_loader_callback(e) # load custom exception
else:
print(traceback.format_exc())
e = HTTPException()
if blueprint is not None:
if blueprint.name in self._errorhandlers:
return self._errorhandlers[blueprint.name](e)
else:
if None in self._errorhandlers:
return self._errorhandlers[None](e)
return e
评论列表
文章目录