view lib/cycloneerr.py @ 967:2489d111f4f1

whitespace Ignore-this: 29ddf8925c373bdb1ec8f62a01f0ac4f darcs-hash:20150322074155-312f9-2dd631ff19a153041b3e869536d7c277cba2b768
author drewp <drewp@bigasterisk.com>
date Sun, 22 Mar 2015 00:41:55 -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),
        }