view lib/cycloneerr.py @ 463:1ceb26846eca

add separate :matchPredicate support. some build and log edits. Ignore-this: acdab8c2859e5f8622b491228d0c74dd
author drewp@bigasterisk.com
date Sat, 20 Apr 2019 23:36:30 -0700
parents 3d51d4b63497
children a63549a50b3f
line wrap: on
line source

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