Update exceptions.py

Call force_text() only if detail is a string, if detail is other data type better leave raw. The idea is give the programmer the possibility to manage other detail data type when catch the exception
This commit is contained in:
Manuel Zaforas 2014-12-17 18:52:50 +01:00
parent df29641f20
commit bd482284f9

View File

@ -39,10 +39,10 @@ class APIException(Exception):
default_detail = _('A server error occured')
def __init__(self, detail=None):
if detail is not None:
self.detail = force_text(detail)
else:
if detail is None:
self.detail = force_text(self.default_detail)
elif isinstance(detail, basestring):
self.detail = force_text(detail)
def __str__(self):
return self.detail