view lib/cycloneerr.py @ 1166:f0d752c0a772

CC don't talk to dmx if you have no subterms (now the norm) Ignore-this: 910d809f7cb8bed5a3dd9aa4d1144e01
author drewp@bigasterisk.com
date Sun, 15 Jun 2014 02:53:33 +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),
        }