view lib/cycloneerr/cycloneerr.py @ 1441:94bb8408e6ed

fix precision of ledstrip paras Ignore-this: d0841f1170755b08cb63de8f8af776c6 darcs-hash:a89893534e614b3f821c212e7a648050cc6cc176
author drewp <drewp@bigasterisk.com>
date Mon, 12 Aug 2019 10:08:23 -0700
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),
        }