django validationerr 加到 util exception
This commit is contained in:
parent
9227038836
commit
348ef951c6
|
@ -1,6 +1,6 @@
|
|||
import traceback
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.http import Http404
|
||||
import logging
|
||||
from rest_framework import exceptions
|
||||
|
@ -21,6 +21,8 @@ def custom_exception_hander(exc, context):
|
|||
exc = exceptions.NotFound()
|
||||
elif isinstance(exc, PermissionDenied):
|
||||
exc = exceptions.PermissionDenied()
|
||||
elif isinstance(exc, ValidationError):
|
||||
exc = exceptions.ValidationError(exc.message)
|
||||
|
||||
request_id = getattr(context['request'], 'request_id', None)
|
||||
if isinstance(exc, exceptions.APIException):
|
||||
|
|
Loading…
Reference in New Issue