Commit a8eb08b7 authored by 钟尚武's avatar 钟尚武

Merge branch 'shangwu/hotfix-tag-set' into 'test'

词集接口增加错误处理

See merge request !337
parents c5f471ff 11671c3b
......@@ -6,6 +6,7 @@
import json
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
from alpha_types.venus.error import ERROR
class TagListView(APIView):
......@@ -281,8 +282,9 @@ class TagSetDeleteView(APIView):
error_logger.error(u'删除词集失败%s', e)
raise
return {
"status": 1
}
"message": "删除成功",
"code": 200
}
class TagSetUpdateOrCreateView(APIView):
......@@ -296,17 +298,31 @@ class TagSetUpdateOrCreateView(APIView):
try:
data = self.rpc['venus/sun/tag_set/update'](tag_set_id=tag_set_id, name=name, tag_ids=tag_ids).unwrap()
except Exception as e:
error_logger.error(u'更新词集失败%s', e)
raise
if e.error == ERROR.TAG_SET_HAD_EXIST:
return {
'message': e.message,
'code': 500
}
else:
error_logger.error(u'更新词集失败%s', e)
raise
return {
"status": 1
"message": "更新成功",
"code": 200
}
else:
try:
data = self.rpc['venus/sun/tag_set/create'](name=name, tag_ids=tag_ids).unwrap()
except Exception as e:
error_logger.error(u'创建词集失败%s', e)
raise
if e.error == ERROR.TAG_SET_HAD_EXIST:
return {
'message': e.message,
'code': 500
}
else:
error_logger.error(u'创建词集失败%s', e)
raise
return {
"status": 1
"message": "创建成功",
"code": 200
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment