Fixed #5884 -- Added better display error handling for template variables.
Combined work from Karen Tracey and Thomas Güttler. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7260 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
732074541a
commit
b5adaec4c2
|
@ -129,7 +129,10 @@ class VariableDoesNotExist(Exception):
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.msg % self.params
|
return unicode(self).encode('utf-8')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.msg % tuple([force_unicode(p, errors='replace') for p in self.params])
|
||||||
|
|
||||||
class InvalidTemplateLibrary(Exception):
|
class InvalidTemplateLibrary(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DebugNodeList(NodeList):
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e)
|
wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))
|
||||||
wrapped.source = node.source
|
wrapped.source = node.source
|
||||||
wrapped.exc_info = exc_info()
|
wrapped.exc_info = exc_info()
|
||||||
raise wrapped
|
raise wrapped
|
||||||
|
|
Loading…
Reference in New Issue