view lib/cycloneerr.py @ 1237:c8ac652d37b7

switch to uart Ignore-this: b5285d12100bc182b970ea392f48e259 darcs-hash:c8280607c51cb0da02361600f2fa3d62be66b83b
author drewp <drewp@bigasterisk.com>
date Tue, 09 Apr 2019 09:05:42 -0700
parents 5d97ed6118db
children 3d51d4b63497
line wrap: on
line source

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