view lib/cycloneerr/cycloneerr.py @ 1512:1e9cfec1be78

don't require first arg on PatchedGraph.serialize Ignore-this: bc695823e03dbd012e03efa4e40b6aca darcs-hash:1dbf9271b5ca55c78987c474ef223af9d5b811d2
author drewp <drewp@bigasterisk.com>
date Mon, 03 Feb 2020 23:46:29 -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),
        }