|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
import traceback
|
|
|
|
|
from logging import getLogger
|
|
|
|
|
|
|
|
|
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist as DJObjectDoesNotExist
|
|
|
|
|
from django.db.models.deletion import ProtectedError
|
|
|
|
|
from django.http import Http404
|
|
|
|
|
from django.utils.translation import gettext
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
from rest_framework import exceptions
|
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
from rest_framework.views import set_rollback
|
|
|
|
@ -29,6 +31,9 @@ def extract_object_name(exc, index=0):
|
|
|
|
|
|
|
|
|
|
def common_exception_handler(exc, context):
|
|
|
|
|
# logger.exception('')
|
|
|
|
|
if settings.DEBUG_DEV:
|
|
|
|
|
logger.exception('Print traceback exception for Debug')
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
if isinstance(exc, Http404):
|
|
|
|
|
exc = JMSObjectDoesNotExist(object_name=extract_object_name(exc, 1))
|
|
|
|
|