view lib/cycloneerr.py @ 1291:c1b0813372cc

move to /my/proj/hardware/busyboxArduino. hardware is still around and this has notes on how to use it. Ignore-this: 7743f57abef17980c595b1686abf646a darcs-hash:75f747175229c26222b107b64458d0c01845e17d
author drewp <drewp@bigasterisk.com>
date Sun, 21 Apr 2019 01:26:58 -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),
        }