view lib/cycloneerr/cycloneerr.py @ 1522:040e12a696a9

influx host name; reformat Ignore-this: cf8651143d3459e64aefa51da973c54e darcs-hash:1e4b44bdb36d68876a443ed255b71de3608356d9
author drewp <drewp@bigasterisk.com>
date Wed, 05 Feb 2020 00:22:48 -0800
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),
        }