Ticket #6537: 6537.diff

File 6537.diff, 2.8 KB (added by Thomas Güttler, 17 years ago)
  • django/views/debug.py

     
    22import re
    33import sys
    44import datetime
     5import traceback
    56
    67from django.conf import settings
    78from django.template import Template, Context, TemplateDoesNotExist
     
    104105            })
    105106    if settings.TEMPLATE_DEBUG and hasattr(exc_value, 'source'):
    106107        exc_type, exc_value, tb, template_info = get_template_exception_info(exc_type, exc_value, tb)
     108    original_exc_info=getattr(exc_value, 'original_exc_info', None)
     109    if original_exc_info:
     110        original_exc_info=''.join([smart_unicode(line, errors='replace') for line in traceback.format_exception(*original_exc_info)])
     111                                   
    107112    frames = []
    108113    while tb is not None:
    109114        # support for __traceback_hide__ which is used by a few libraries
     
    165170        'template_info': template_info,
    166171        'template_does_not_exist': template_does_not_exist,
    167172        'loader_debug_info': loader_debug_info,
     173        'original_exc_info': original_exc_info,
    168174    })
    169175    return t.render(c)
    170176
     
    379385      <th>Exception Location:</th>
    380386      <td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
    381387    </tr>
     388    {% if original_exc_info %}
    382389    <tr>
     390      <th>Original Exception:</th>
     391      <td><pre>{{ original_exc_info|escape }}</pre></td>
     392    </tr>
     393    {% endif %}
     394    <tr>
    383395      <th>Python Executable:</th>
    384396      <td>{{ sys_executable|escape }}</td>
    385397    </tr>
  • django/core/urlresolvers.py

     
    252256            except Exception, e:
    253257                # Either an invalid urlconf_name, such as "foo.bar.", or some
    254258                # kind of problem during the actual import.
    255                 raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)
     259                import sys
     260                raise ImproperlyConfigured("Error while importing URLconf %r: %s" % (self.urlconf_name, e), original_exc_info=sys.exc_info())
    256261            return self._urlconf_module
    257262    urlconf_module = property(_get_urlconf_module)
    258263
  • django/core/exceptions.py

     
    2626
    2727class ImproperlyConfigured(Exception):
    2828    "Django is somehow improperly configured"
    29     pass
     29    def __init__(self, msg, original_exc_info=None):
     30        Exception.__init__(self, msg)
     31        self.original_exc_info=original_exc_info
Back to Top