Fix worong serialization of exceptions generated by domain application.
parent
71afb1cf79
commit
855c3c7eb5
|
@ -3,7 +3,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from django import http
|
from django import http
|
||||||
|
|
||||||
from taiga.base import domains
|
from taiga.base import domains
|
||||||
from taiga.base.exceptions import format_exception
|
from taiga.base.exceptions import format_exception
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from rest_framework import status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
|
from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
|
|
||||||
|
@ -76,16 +77,13 @@ class NotAuthenticated(exceptions.NotAuthenticated):
|
||||||
|
|
||||||
|
|
||||||
def format_exception(exc):
|
def format_exception(exc):
|
||||||
# TODO: this method need a refactor.
|
|
||||||
# TODO: should return in uniform way all exceptions.
|
|
||||||
|
|
||||||
if isinstance(exc.detail, (dict, list, tuple,)):
|
if isinstance(exc.detail, (dict, list, tuple,)):
|
||||||
detail = exc.detail
|
detail = exc.detail
|
||||||
else:
|
else:
|
||||||
class_name = exc.__class__.__name__
|
class_name = exc.__class__.__name__
|
||||||
class_module = exc.__class__.__module__
|
class_module = exc.__class__.__module__
|
||||||
detail = {
|
detail = {
|
||||||
"_error_message": exc.detail,
|
"_error_message": force_text(exc.detail),
|
||||||
"_error_type": "{0}.{1}".format(class_module, class_name)
|
"_error_type": "{0}.{1}".format(class_module, class_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue