annotate lib/cycloneerr.py @ 1573:20f48a0e7135

hover mode shows best match Ignore-this: 3b25ed8ebb8e6be38a3afa0d077e78ba
author Drew Perttula <drewp@bigasterisk.com>
date Sun, 28 May 2017 09:05:37 +0000
parents 473db8bebb8f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1060
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
1 import httplib, cgi
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
3 class PrettyErrorHandler(object):
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
4 """
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 mix-in to improve cyclone.web.RequestHandler
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 """
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
7 def get_error_html(self, status_code, **kwargs):
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
8 try:
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
9 tb = kwargs['exception'].getTraceback()
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
10 except AttributeError:
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
11 tb = ""
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12 return "<html><title>%(code)d: %(message)s</title>" \
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
13 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % {
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
14 "code": status_code,
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
15 "message": httplib.responses[status_code],
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
16 "tb" : cgi.escape(tb),
473db8bebb8f install a copy of cycloneerr.py
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
17 }