mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Merge 1dae174ae4
into 139c8fe3d1
This commit is contained in:
commit
680405bba9
|
@ -81,14 +81,18 @@ def exception_handler(exc, context):
|
||||||
|
|
||||||
elif isinstance(exc, Http404):
|
elif isinstance(exc, Http404):
|
||||||
msg = _('Not found.')
|
msg = _('Not found.')
|
||||||
data = {'detail': six.text_type(msg)}
|
data = {'detail': {api_settings.NON_FIELD_ERRORS_KEY: [{
|
||||||
|
'message': six.text_type(msg),
|
||||||
|
'code': 'not_found'}]}}
|
||||||
|
|
||||||
set_rollback()
|
set_rollback()
|
||||||
return Response(data, status=status.HTTP_404_NOT_FOUND)
|
return Response(data, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
elif isinstance(exc, PermissionDenied):
|
elif isinstance(exc, PermissionDenied):
|
||||||
msg = _('Permission denied.')
|
msg = _('Permission denied.')
|
||||||
data = {'detail': six.text_type(msg)}
|
data = {'detail': {api_settings.NON_FIELD_ERRORS_KEY: [{
|
||||||
|
'message': six.text_type(msg),
|
||||||
|
'code': 'permission_denied'}]}}
|
||||||
|
|
||||||
set_rollback()
|
set_rollback()
|
||||||
return Response(data, status=status.HTTP_403_FORBIDDEN)
|
return Response(data, status=status.HTTP_403_FORBIDDEN)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user