Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1852 -- Improved TemplateSyntaxError to display the original e…

…xception 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
  • Loading branch information...
commit 55c9e98d86e717a3da832fc309947d70a68ffdb0 1 parent 51f6a94
Adrian Holovaty authored May 15, 2006
1  AUTHORS
@@ -88,6 +88,7 @@ answer newbie questions, and generally made Django that much better:
88 88
     Robin Munn <http://www.geekforgod.com/>
89 89
     Nebojša Dorđević
90 90
     Sam Newman <http://www.magpiebrain.com/>
  91
+    Neal Norwitz <nnorwitz@google.com>
91 92
     oggie rob <oz.robharvey@gmail.com>
92 93
     pgross@thoughtworks.com
93 94
     phaedo <http://phaedo.cx/>
15  django/template/__init__.py
@@ -91,7 +91,20 @@
91 91
 builtins = []
92 92
 
93 93
 class TemplateSyntaxError(Exception):
94  
-    pass
  94
+    def __str__(self):
  95
+        try:
  96
+            import cStringIO as StringIO
  97
+        except ImportError:
  98
+            import StringIO
  99
+        output = StringIO.StringIO()
  100
+        output.write(Exception.__str__(self))
  101
+        # Check if we wrapped an exception and print that too.
  102
+        if hasattr(self, 'exc_info'):
  103
+            import traceback
  104
+            output.write('\n\nOriginal ')
  105
+            e = self.exc_info
  106
+            traceback.print_exception(e[0], e[1], e[2], 500, output)
  107
+        return output.getvalue()
95 108
 
96 109
 class TemplateDoesNotExist(Exception):
97 110
     pass

0 notes on commit 55c9e98

Please sign in to comment.
Something went wrong with that request. Please try again.