Changeset 602


Ignore:
Timestamp:
Jun 13, 2008, 4:03:01 AM (16 years ago)
Author:
price
Message:

one world, one error-reporting mechanism

The email and the web page show the same information from the same template,
with the web page adding chrome and a little text. The same code path handles
CodeErrors? and other exceptions.

Location:
trunk/packages/sipb-xen-www/code
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-www/code/main.py

    r601 r602  
    119119
    120120def error(op, username, fields, err, emsg, traceback):
    121     """Print an error page when a CodeError occurs"""
     121    """Print an error page when an exception occurs"""
    122122    d = dict(op=op, user=username, fields=fields,
    123123             errorMessage=str(err), stderr=emsg, traceback=traceback)
     
    585585def throwError(_, __, ___):
    586586    """Throw an error, to test the error-tracing mechanisms."""
    587     raise CodeError("test of the emergency broadcast system")
     587    raise RuntimeError("test of the emergency broadcast system")
    588588
    589589mapping = dict(list=listVms,
     
    677677            checkpoint.checkpoint('output as a string')
    678678        except Exception, err:
    679             import traceback
    680679            if not fields.has_key('js'):
    681                 if isinstance(err, CodeError):
    682                     self.start('500 Internal Server Error', [('Content-Type', 'text/html')])
    683                     e = revertStandardError()
    684                     s = error(operation, self.username, fields,
    685                               err, e, traceback.format_exc())
    686                     yield str(s)
    687                     return
    688680                if isinstance(err, InvalidInput):
    689681                    self.start('200 OK', [('Content-Type', 'text/html')])
     
    691683                    yield str(invalidInput(operation, self.username, fields, err, e))
    692684                    return
    693             self.start('500 Internal Server Error', [('Content-Type', 'text/plain')])
    694             send_error_mail('xvm error: %s' % (err,),
    695                             '%s\n' % (traceback.format_exc(),))
    696             yield '''Uh-oh!  We experienced an error.
    697 Sorry about that.  We've gotten mail about it.
    698 
    699 Feel free to poke us at xvm@mit.edu if this bug is
    700 consistently biting you and we don't seem to be fixing it.
    701 
    702 In case you're curious, the gory details are here.
    703 ----
    704 %s
    705 ----
    706 %s
    707 ----''' % (str(err), traceback.format_exc())
     685            import traceback
     686            self.start('500 Internal Server Error',
     687                       [('Content-Type', 'text/html')])
     688            e = revertStandardError()
     689            s = error(operation, self.username, fields,
     690                           err, e, traceback.format_exc())
     691            yield str(s)
     692            return
    708693        status = headers.setdefault('Status', '200 OK')
    709694        del headers['Status']
  • trunk/packages/sipb-xen-www/code/templates/error_raw.tmpl

    r601 r602  
    1010---- end error output
    1111
    12 Traceback:
    1312$traceback
Note: See TracChangeset for help on using the changeset viewer.