view lib/cycloneerr/cycloneerr.py @ 1426:c3c2418d138c

fix pushconfig host lookup Ignore-this: d53a114fdfb3bd3bf355a0c7293a1c7b darcs-hash:6306237a7df35fffb57f27c31a971107608f979e
author drewp <drewp@bigasterisk.com>
date Wed, 07 Aug 2019 21:06:46 -0700
parents c5bd44f90ced
children fd94061db75c
line wrap: on
line source

try:
    import http.client as httplib
except ImportError:
    import httplib  # type: ignore
import 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),
        }