view lib/cycloneerr.py @ 958:f83d494b0f31

start buttons+lcd program Ignore-this: 7bcbbbbbc21984988c87a06e1cb582f1 darcs-hash:20150104073406-312f9-0fdaf43c639503fac5b4100dcf0f8ede1463866b
author drewp <drewp@bigasterisk.com>
date Sat, 03 Jan 2015 23:34:06 -0800
parents bebb8f7c5a3e
children 053fd552b675
line wrap: on
line source

import httplib, 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),
        }