view lib/cycloneerr.py @ 1309:b54164bcded3

rm old code to read a shaft encoder on an rpi, and a simple thermostat service that switches a house heater on Ignore-this: b199393215c152f5daf5f0c781387d51 darcs-hash:3e25f2056470b710fb1cf5bfc34f585914469d56
author drewp <drewp@bigasterisk.com>
date Sun, 21 Apr 2019 03:18:45 -0700
parents 202edadf4351
children
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),
        }