def error_response(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
try:
result = func(self, *args, **kwargs)
except Exception as ex:
if not isinstance(ex, (web.HTTPError, ExecutionError, GraphQLError)):
tb = ''.join(traceback.format_exception(*sys.exc_info()))
app_log.error('Error: {0} {1}'.format(ex, tb))
self.set_status(error_status(ex))
error_json = json_encode({'errors': error_format(ex)})
app_log.debug('error_json: %s', error_json)
self.write(error_json)
else:
return result
return wrapper
graphql_handler.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录