annotate lib/cycloneerr.py @ 1237:c8ac652d37b7

switch to uart Ignore-this: b5285d12100bc182b970ea392f48e259 darcs-hash:c8280607c51cb0da02361600f2fa3d62be66b83b
author drewp <drewp@bigasterisk.com>
date Tue, 09 Apr 2019 09:05:42 -0700
parents 5d97ed6118db
children 3d51d4b63497
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1233
5d97ed6118db some py3
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
1 try:
5d97ed6118db some py3
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
2 import httplib
5d97ed6118db some py3
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
3 except ImportError:
5d97ed6118db some py3
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
4 import http.client as httplib
5d97ed6118db some py3
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
5 import cgi
809
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 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
8 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 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
10 """
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11 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
12 try:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 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
14 except AttributeError:
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15 tb = ""
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 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
17 "<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
18 "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
19 "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
20 "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
21 }