Mercurial > code > home > repos > light9
diff lib/cycloneerr.py @ 1060:473db8bebb8f
install a copy of cycloneerr.py
Ignore-this: cd8b94a251fff5cd9412775258a1f2cf
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 02 Jun 2014 00:19:38 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/cycloneerr.py Mon Jun 02 00:19:38 2014 +0000 @@ -0,0 +1,17 @@ +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), + }