diff -r 088aa2da1340 -r fbccc1648d79 error.py --- /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', ("""\ +500 Internal Server Error +

Oops!

+

+ 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. +

+

+ If you do so, please include the following information: +

+

Details:

+
%(traceback)s
+""" % dict( + traceback = ''.join(traceback.format_exception(*exc_info)) + )).encode('utf-8')) +