view lib/cycloneerr.py @ 1431:f85cc11b3e8c

checkpoint show data Ignore-this: 7dc477a7921f92dc9cc8115c6cc2b9cf
author drewp@bigasterisk.com
date Sat, 11 Jun 2016 17:15:30 +0000
parents 473db8bebb8f
children
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),
        }