Fixed #1852 -- Improved TemplateSyntaxError to display the original exception if str() of the exception raises an exception in itself. Thanks, nnorwitz@google.com

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-05-15 04:24:48 +00:00
parent 51f6a9442c
commit 55c9e98d86
2 changed files with 15 additions and 1 deletions

View File

@ -88,6 +88,7 @@ answer newbie questions, and generally made Django that much better:
Robin Munn <http://www.geekforgod.com/> Robin Munn <http://www.geekforgod.com/>
Nebojša Dorđević Nebojša Dorđević
Sam Newman <http://www.magpiebrain.com/> Sam Newman <http://www.magpiebrain.com/>
Neal Norwitz <nnorwitz@google.com>
oggie rob <oz.robharvey@gmail.com> oggie rob <oz.robharvey@gmail.com>
pgross@thoughtworks.com pgross@thoughtworks.com
phaedo <http://phaedo.cx/> phaedo <http://phaedo.cx/>

View File

@ -91,7 +91,20 @@ libraries = {}
builtins = [] builtins = []
class TemplateSyntaxError(Exception): class TemplateSyntaxError(Exception):
pass def __str__(self):
try:
import cStringIO as StringIO
except ImportError:
import StringIO
output = StringIO.StringIO()
output.write(Exception.__str__(self))
# Check if we wrapped an exception and print that too.
if hasattr(self, 'exc_info'):
import traceback
output.write('\n\nOriginal ')
e = self.exc_info
traceback.print_exception(e[0], e[1], e[2], 500, output)
return output.getvalue()
class TemplateDoesNotExist(Exception): class TemplateDoesNotExist(Exception):
pass pass