From a9da31c5588575b4e020db099770a23c79748445 Mon Sep 17 00:00:00 2001
From: Greg Price
Date: Fri, 13 Jun 2008 03:42:51 -0400
Subject: [PATCH] collect all available data, in CodeError case for now
svn path=/trunk/packages/sipb-xen-www/; revision=600
---
code/main.py | 14 +++++++-------
code/templates/error.tmpl | 14 ++++++++++++--
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/code/main.py b/code/main.py
index 7531852..01d6e39 100755
--- a/code/main.py
+++ b/code/main.py
@@ -30,7 +30,6 @@ def printError():
if __name__ == '__main__':
import atexit
atexit.register(printError)
- sys.stderr = StringIO()
sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages')
@@ -118,13 +117,13 @@ class Defaults:
DEFAULT_HEADERS = {'Content-Type': 'text/html'}
-def error(op, username, fields, err, emsg):
+def error(op, username, fields, err, emsg, traceback):
"""Print an error page when a CodeError occurs"""
send_error_mail('xvm error on %s for %s: %s' % (op, username, err),
'error on %s for %s: %s\n\n%s\n'
% (op, username, err, emsg))
- d = dict(op=op, user=username, errorMessage=str(err),
- stderr=emsg)
+ d = dict(op=op, user=username, fields=fields,
+ errorMessage=str(err), stderr=emsg, traceback=traceback)
return templates.error(searchList=[d])
def invalidInput(op, username, fields, err, emsg):
@@ -636,8 +635,8 @@ class App:
self.state.environ = environ
def __iter__(self):
+ sys.stderr = StringIO()
fields = cgi.FieldStorage(fp=self.environ['wsgi.input'], environ=self.environ)
- print >> sys.stderr, fields
operation = self.environ.get('PATH_INFO', '')
if not operation:
self.start("301 Moved Permanently", [('Location',
@@ -676,11 +675,13 @@ class App:
output_string = str(output)
checkpoint.checkpoint('output as a string')
except Exception, err:
+ import traceback
if not fields.has_key('js'):
if isinstance(err, CodeError):
self.start('500 Internal Server Error', [('Content-Type', 'text/html')])
e = revertStandardError()
- s = error(operation, self.username, fields, err, e)
+ s = error(operation, self.username, fields,
+ err, e, traceback.format_exc())
yield str(s)
return
if isinstance(err, InvalidInput):
@@ -689,7 +690,6 @@ class App:
yield str(invalidInput(operation, self.username, fields, err, e))
return
self.start('500 Internal Server Error', [('Content-Type', 'text/plain')])
- import traceback
send_error_mail('xvm error: %s' % (err,),
'%s\n' % (traceback.format_exc(),))
yield '''Uh-oh! We experienced an error.
diff --git a/code/templates/error.tmpl b/code/templates/error.tmpl
index 37f9cc6..b11deaa 100644
--- a/code/templates/error.tmpl
+++ b/code/templates/error.tmpl
@@ -16,7 +16,17 @@ consistently biting you and we don't seem to be fixing it.
Error on operation $op for user $user: $errorMessage
-Error output (if any):
-$stderr
+
+Fields:
+#for $f in $fields:
+$f=$fields[$f].value
+#end for
+
+Error output:
+$stderr#slurp
+---- end error output
+
+Traceback:
+$traceback
#end def
--
1.7.9.5