view lib/cycloneerr/cycloneerr.py @ 1428:56e07d3f0930

frontdoor configs; move device class timing to greplin stats Ignore-this: f32495ae0d3b4c6f50fe1ba46c57abcd darcs-hash:c8b6f8460b858868837dc9c98f844528531fe98c
author drewp <drewp@bigasterisk.com>
date Thu, 08 Aug 2019 16:50:14 -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),
        }