Example #1
0
 def global_error_handler(exception):
     """
     全局的异常处理:
     1. 打印到 logger :以便记录异常信息
     2. 封装成 Result 对象,以 json 格式返回到 Client
     :param exception:
     :return:
     """
     LOG.error("%s\n%s", exception, traceback.format_exc())
     return jsonify(Result.error(exception)), 500
Example #2
0
 def internal_error_handler(exception):
     LOG.error("[400] %s\n%s", exception, traceback.format_exc())
     return jsonify(Result.error(exception)), 400
Example #3
0
 def service_error_handler(exception):
     LOG.error("%s\n%s", exception, traceback.format_exc())
     return jsonify(Result.error(exception)), 500
Example #4
0
 def page_not_found(error):
     return jsonify(Result.error('[404] Page not found!')), 404