﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1852	Print original exception when an unknown error occurs in template	nnorwitz@…	Adrian Holovaty	"We had a problem when we updated a Model, but not the DB.  Loading the template failed and we got a useless error message because of catching the original exception and wrapping it.  Only the TemplateSyntaxError was printed, not the original exception which was very misleading.  This was with 0.91, but HEAD has the same issue.  Below is a patch that fixes the problem.  I didn't see a way to upload a file as a patch.


--- template/__init__.py.orig   2006-05-12 11:14:27.000000000 -0700
+++ template/__init__.py        2006-05-12 11:14:00.000000000 -0700
@@ -90,7 +90,20 @@
 builtins = []
  
 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 ContextPopException(Exception):
     ""pop() has been called more times than push()""

"	enhancement	closed	Template system		normal	fixed			Unreviewed	0	0	0	0	0	0
