--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/error.py Mon Feb 16 02:09:14 2009 +0200
@@ -0,0 +1,36 @@
+"""
+ Build error messages
+"""
+
+import traceback, sys
+
+def build_error (exc_info=None) :
+ """
+ Dumps out a raw traceback of the given/current exception to stdout.
+
+ Returns a (status, content-type, body) tuple, with all components being non-unicode strs.
+ """
+
+
+ # default
+ if not exc_info :
+ exc_info = sys.exc_info()
+
+ # return
+ return ('500 Internal Server Error', 'text/html; charset=UTF-8', ("""\
+<html><head><title>500 Internal Server Error</title></head><body>
+<h1>Oops!</h1>
+<p>
+ An error occured, which was not logged, and will not be reported to anybody. It might be your fault, or it might be
+ the programmer's, but it's probably not mine. If you think you really care, you can try poking the administrator of
+ this site to see if they respond.
+</p>
+<p>
+ If you do so, please include the following information:
+</p>
+<h2>Details:</h2>
+<pre>%(traceback)s</pre>
+</body></html>""" % dict(
+ traceback = ''.join(traceback.format_exception(*exc_info))
+ )).encode('utf-8'))
+