Mercurial > code > home > repos > homeauto
annotate lib/cycloneerr.py @ 4:be855a111619
move a bunch of services into this tree, give them all web status pages
Ignore-this: a11e90f9d2cd9470565c743f54943c4b
author | drewp@bigasterisk.com |
---|---|
date | Mon, 08 Aug 2011 00:31:31 -0700 |
parents | |
children | 053fd552b675 |
rev | line source |
---|---|
4
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
1 import httplib, cgi |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
3 class PrettyErrorHandler(object): |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
4 """ |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
5 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
|
6 """ |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
7 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
|
8 try: |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
9 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
|
10 except AttributeError: |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
11 tb = "" |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
12 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
|
13 "<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
|
14 "code": status_code, |
be855a111619
move a bunch of services into this tree, give them all web status pages
drewp@bigasterisk.com
parents:
diff
changeset
|
15 "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
|
16 "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
|
17 } |