send mail on all exceptions
authorGreg Price <price@mit.edu>
Fri, 13 Jun 2008 06:58:13 +0000 (02:58 -0400)
committerGreg Price <price@mit.edu>
Fri, 13 Jun 2008 06:58:13 +0000 (02:58 -0400)
svn path=/trunk/packages/sipb-xen-www/; revision=599

code/main.py
code/templates/error.tmpl

index 5874928..7531852 100755 (executable)
@@ -17,7 +17,7 @@ def revertStandardError():
     """Move stderr to stdout, and return the contents of the old stderr."""
     errio = sys.stderr
     if not isinstance(errio, StringIO):
     """Move stderr to stdout, and return the contents of the old stderr."""
     errio = sys.stderr
     if not isinstance(errio, StringIO):
-        return None
+        return ''
     sys.stderr = sys.stdout
     errio.seek(0)
     return errio.read()
     sys.stderr = sys.stdout
     errio.seek(0)
     return errio.read()
@@ -120,6 +120,9 @@ DEFAULT_HEADERS = {'Content-Type': 'text/html'}
 
 def error(op, username, fields, err, emsg):
     """Print an error page when a CodeError occurs"""
 
 def error(op, username, fields, err, emsg):
     """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)
     return templates.error(searchList=[d])
     d = dict(op=op, user=username, errorMessage=str(err),
              stderr=emsg)
     return templates.error(searchList=[d])
@@ -581,7 +584,7 @@ def unauthFront(_, _2, fields):
 
 def throwError(_, __, ___):
     """Throw an error, to test the error-tracing mechanisms."""
 
 def throwError(_, __, ___):
     """Throw an error, to test the error-tracing mechanisms."""
-    raise RuntimeError("This is a test of the emergency broadcast system.")
+    raise CodeError("test of the emergency broadcast system")
 
 mapping = dict(list=listVms,
                vnc=vnc,
 
 mapping = dict(list=listVms,
                vnc=vnc,
index b129599..37f9cc6 100644 (file)
@@ -6,7 +6,17 @@ ERROR!
 #end def
 
 #def body
 #end def
 
 #def body
-<p>$errorMessage in operation $op.  This shouldn't happen!  Please
-email xvm@mit.edu to explain how it happened.  Stderr:</p>
-<pre>$stderr</pre>
+<p>Uh-oh!  We experienced an error.  Sorry about that.  We've gotten
+mail about it.</p>
+
+<p>Feel free to poke us at <tt>xvm@mit.edu</tt> if this bug is
+consistently biting you and we don't seem to be fixing it.</p>
+
+<p>In case you're curious, the gory details are here.</p>
+
+<pre>
+Error on operation $op for user $user: $errorMessage
+Error output (if any):
+$stderr
+</pre>
 #end def
 #end def