view lib/cycloneerr.py @ 1136:1e43ec4a5f23

build and import updates for rdfdb, etc Ignore-this: 233cb2b31f03be51695f0fff40eecca7 darcs-hash:92c1c526292f9013ad41d2e3b6d11add8fff02ae
author drewp <drewp@bigasterisk.com>
date Mon, 19 Feb 2018 04:21:28 -0800
parents bebb8f7c5a3e
children 053fd552b675
line wrap: on
line source

import httplib, cgi

class PrettyErrorHandler(object):
    """
    mix-in to improve cyclone.web.RequestHandler
    """
    def get_error_html(self, status_code, **kwargs):
        try:
            tb = kwargs['exception'].getTraceback()
        except AttributeError:
            tb = ""
        return "<html><title>%(code)d: %(message)s</title>" \
               "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % {
            "code": status_code,
            "message": httplib.responses[status_code],
            "tb" : cgi.escape(tb),
        }