view lib/cycloneerr.py @ 894:3ad6b7bcdaff

shuttlepro: some old changes Ignore-this: 980a9ffa0b084bd46db880b4b3621a02 darcs-hash:20130802150605-312f9-c293c465516f42c8397aad7f48c228526cf46295
author drewp <drewp@bigasterisk.com>
date Fri, 02 Aug 2013 08:06:05 -0700
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),
        }