Mercurial > code > home > repos > homeauto
annotate lib/cycloneerr.py @ 1154:5da3a85b59e4
more robust about not accumulating old stmts
Ignore-this: ee8618c8341d028fd7bd3596cd16a43d
darcs-hash:447cf599c2a1633481bc68fc3bc2fa5b8352fbf5
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 16 Apr 2018 22:16:15 -0700 |
parents | bebb8f7c5a3e |
children | 053fd552b675 |
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 } |