def handle_500(self, request, err):
        log.exception("Error handling HTTP request: %s %s" %
                      (request.method, request.url))
        if not self.debug:
            return error(500, request=request)

        # See if we can highlight the traceback.
        tb = getattr(request, '_tb', None) or traceback.format_exc()

        # Try to highlight the traceback.
        if hasattr(self, 'highlight_traceback'):
            try:
                tb = self.highlight_traceback(request, err, tb)
                if not u"<pre>" in tb:
                    tb = u"<pre>%s</pre>" % tb
            except Exception as err:
                log.exception("Error in highlight_traceback for %r." % self)
                tb = u"<pre>%s</pre>" % tb
        else:
            tb = u"<pre>%s</pre>" % tb

        response = u"\n".join([
            u"<h2>Traceback</h2>", tb,
            #u'<div id="console"><script type="text/javascript">%s</script></div>' % CONSOLE_JS,
            u"<h2>Route</h2>",
            u"<pre>route name   = %r" % getattr(request, "route_name", None),
            u"match groups = %r" % (request.match.groups() if request.match else None,),
            (u"match values = %r</pre>" % request._converted_match) if hasattr(request, '_converted_match') else u"</pre>",
            u"<h2>HTTP Request</h2>",
            request.__html__()
        ])

        return error(response, 500, request=request)

    ##### Routing Table Builder ###############################################
dataset/ETHPy150Open ecdavis/pants/pants/web/application.py/Application.handle_500/original