示例#1
0
def error_handler(error):
    if hasattr(error, 'name'):
        msg = error.name
        code = error.code
    else:
        msg = error.message
        code = 500
    return ApiResult({'message': msg}, status=code)
示例#2
0
 def make_response(self, rv):
     if isinstance(rv, dict):
         if 'r' not in rv:
             rv['r'] = 0
         rv = ApiResult(rv)
     if isinstance(rv, ApiResult):
         return rv.to_response()
     return Flask.make_response(self, rv)
 def to_result(self):
     return ApiResult({'msg': self.message, 'r': self.code},
                      status=self.status)
示例#4
0
 def to_result(self):
     return ApiResult({'message': self.message, 'r': 1}, status=self.status)