jhacker
2018-06-06 16:02:39 +08:00
def _find_error_handler(self, e):
"""Return a registered error handler for an exception in this order:
blueprint handler for a specific code, app handler for a specific code,
blueprint handler for an exception class, app handler for an exception
class, or ``None`` if a suitable handler is not found.
"""
exc_class, code = self._get_exc_class_and_code(type(e))
for name, c in (
(request.blueprint, code), (None, code),
(request.blueprint, None), (None, None)
):
handler_map = self.error_handler_spec.setdefault(name, {}).get(c)
看了下 Flask 相关的源码,貌似在 request.blueprint 这一步中本来是获取蓝图名称的,但是我调试后值一直为 None,也就是使用 app.errorhandler 进行装饰的函数