Ticket #11461: template-dont-wrap-exception.diff
File template-dont-wrap-exception.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/template/debug.py
69 69 def render_node(self, node, context): 70 70 try: 71 71 result = node.render(context) 72 except TemplateSyntaxError, e:72 except Exception, e: 73 73 if not hasattr(e, 'source'): 74 74 e.source = node.source 75 75 raise 76 except Exception, e:77 from sys import exc_info78 wrapped = TemplateSyntaxError(u'Caught an exception while rendering: %s' % force_unicode(e, errors='replace'))79 wrapped.source = node.source80 wrapped.exc_info = exc_info()81 raise wrapped82 76 return result 83 77 84 78 class DebugVariableNode(VariableNode): -
tests/regressiontests/templates/tests.py
158 158 159 159 def test_url_reverse_no_settings_module(self): 160 160 # Regression test for #9005 161 from django.template import Template, Context, TemplateSyntaxError 161 from django.template import Template, Context 162 from django.core.urlresolvers import NoReverseMatch 162 163 163 164 old_settings_module = settings.SETTINGS_MODULE 164 165 old_template_debug = settings.TEMPLATE_DEBUG … … 170 171 c = Context() 171 172 try: 172 173 rendered = t.render(c) 173 except TemplateSyntaxError, e:174 except NoReverseMatch, e: 174 175 # Assert that we are getting the template syntax error and not the 175 176 # string encoding error. 176 self.assertEquals(e.args[0], " Caught an exception while rendering:Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.")177 self.assertEquals(e.args[0], "Reverse for 'will_not_match' with arguments '()' and keyword arguments '{}' not found.") 177 178 178 179 settings.SETTINGS_MODULE = old_settings_module 179 180 settings.TEMPLATE_DEBUG = old_template_debug