annotate lib/cycloneerr.py @ 1227:21bc3b07a538

make redeploY Ignore-this: 266f6de943e015040aff9820bd7143d9 darcs-hash:84e6441ae6b48f2b481c9335cf3985f9285298e7
author drewp <drewp@bigasterisk.com>
date Sat, 30 Mar 2019 23:56:08 -0700
parents bebb8f7c5a3e
children 053fd552b675
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 import httplib, cgi
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3 class PrettyErrorHandler(object):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5 mix-in to improve cyclone.web.RequestHandler
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7 def get_error_html(self, status_code, **kwargs):
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 try:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 tb = kwargs['exception'].getTraceback()
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 except AttributeError:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 tb = ""
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 return "<html><title>%(code)d: %(message)s</title>" \
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % {
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14 "code": status_code,
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15 "message": httplib.responses[status_code],
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 "tb" : cgi.escape(tb),
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 }