diff lib/cycloneerr.py @ 809:bebb8f7c5a3e

move a bunch of services into this tree, give them all web status pages Ignore-this: a11e90f9d2cd9470565c743f54943c4b darcs-hash:20110808073131-312f9-a7f420d66388cedae458276d672a27a9249f1e2f.gz
author drewp <drewp@bigasterisk.com>
date Mon, 08 Aug 2011 00:31:31 -0700
parents
children 053fd552b675
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/cycloneerr.py	Mon Aug 08 00:31:31 2011 -0700
@@ -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),
+        }