view lib/cycloneerr/cycloneerr.py @ 1315:c5bd44f90ced

make cycloneerr release Ignore-this: 85a8e1a3e04a38167d3c41ebb4a88483 darcs-hash:7e728ee4899b7242222d4cff300f3dd3646b2bf3
author drewp <drewp@bigasterisk.com>
date Mon, 22 Apr 2019 23:21:45 -0700
parents
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),
        }