view lib/cycloneerr.py @ 1024:fcd5ef7439ad

restart_all Ignore-this: 90de4d37694b06f1927a09946435f76 darcs-hash:fb132d4e981299f2cf6c2619f3047871ff5a2283
author drewp <drewp@bigasterisk.com>
date Sun, 03 Jan 2016 02:32:33 -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),
        }