Django

Code

Changeset 2906

Show
Ignore:
Timestamp:
05/14/06 23:24:48 (2 years ago)
Author:
adrian
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r2905 r2906  
    8989    NebojÅ¡a Dorđević 
    9090    Sam Newman <http://www.magpiebrain.com/> 
     91    Neal Norwitz <nnorwitz@google.com> 
    9192    oggie rob <oz.robharvey@gmail.com> 
    9293    pgross@thoughtworks.com 
  • django/trunk/django/template/__init__.py

    r2809 r2906  
    9292 
    9393class 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() 
    95108 
    96109class TemplateDoesNotExist(Exception):