Mercurial > code > home > repos > homeauto
annotate lib/cycloneerr/cycloneerr.py @ 512:11e090ba2731
make cycloneerr release
Ignore-this: 85a8e1a3e04a38167d3c41ebb4a88483
author | drewp@bigasterisk.com |
---|---|
date | Mon, 22 Apr 2019 23:21:45 -0700 |
parents | lib/cycloneerr.py@a63549a50b3f |
children | 71e8ab109f5a |
rev | line source |
---|---|
430 | 1 try: |
472 | 2 import http.client as httplib |
430 | 3 except ImportError: |
472 | 4 import httplib # type: ignore |
430 | 5 import cgi |
4
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
6 |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
7 class PrettyErrorHandler(object): |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
8 """ |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
9 mix-in to improve cyclone.web.RequestHandler |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
10 """ |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
11 def get_error_html(self, status_code, **kwargs): |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
12 try: |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
13 tb = kwargs['exception'].getTraceback() |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
14 except AttributeError: |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
15 tb = "" |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
16 return "<html><title>%(code)d: %(message)s</title>" \ |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
17 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % { |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
18 "code": status_code, |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
19 "message": httplib.responses[status_code], |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
20 "tb" : cgi.escape(tb), |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
21 } |