mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
Add code to exception response
This commit is contained in:
parent
d7a151a71f
commit
13c379c189
|
@ -93,7 +93,7 @@ def exception_handler(exc, context):
|
||||||
if isinstance(exc.detail, (list, dict)):
|
if isinstance(exc.detail, (list, dict)):
|
||||||
data = exc.detail
|
data = exc.detail
|
||||||
else:
|
else:
|
||||||
data = {'detail': exc.detail}
|
data = {'detail': exc.detail, 'code': exc.detail.code}
|
||||||
|
|
||||||
set_rollback()
|
set_rollback()
|
||||||
return Response(data, status=exc.status_code, headers=headers)
|
return Response(data, status=exc.status_code, headers=headers)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user