fix(perms): 重建授权树冲突时,响应里加 code

This commit is contained in:
xinwen
2020-11-03 17:31:25 +08:00
committed by Jiangjie.Bai
parent 531de188d6
commit 231332585d
2 changed files with 7 additions and 4 deletions

View File

@@ -39,10 +39,10 @@ def common_exception_handler(exc, context):
if getattr(exc, 'wait', None):
headers['Retry-After'] = '%d' % exc.wait
if isinstance(exc.detail, (list, dict)):
data = exc.detail
if isinstance(exc.detail, str) and isinstance(exc.get_codes(), str):
data = {'detail': exc.detail, 'code': exc.get_codes()}
else:
data = {'detail': exc.detail}
data = exc.detail
set_rollback()
return Response(data, status=exc.status_code, headers=headers)