Changeset 600


Ignore:
Timestamp:
Jun 13, 2008, 3:42:51 AM (17 years ago)
Author:
price
Message:

collect all available data, in CodeError? case for now

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

Legend:

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

    r599 r600  
    3131    import atexit
    3232    atexit.register(printError)
    33     sys.stderr = StringIO()
    3433
    3534sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages')
     
    119118DEFAULT_HEADERS = {'Content-Type': 'text/html'}
    120119
    121 def error(op, username, fields, err, emsg):
     120def error(op, username, fields, err, emsg, traceback):
    122121    """Print an error page when a CodeError occurs"""
    123122    send_error_mail('xvm error on %s for %s: %s' % (op, username, err),
    124123                    'error on %s for %s: %s\n\n%s\n'
    125124                    % (op, username, err, emsg))
    126     d = dict(op=op, user=username, errorMessage=str(err),
    127              stderr=emsg)
     125    d = dict(op=op, user=username, fields=fields,
     126             errorMessage=str(err), stderr=emsg, traceback=traceback)
    128127    return templates.error(searchList=[d])
    129128
     
    637636
    638637    def __iter__(self):
     638        sys.stderr = StringIO()
    639639        fields = cgi.FieldStorage(fp=self.environ['wsgi.input'], environ=self.environ)
    640         print >> sys.stderr, fields
    641640        operation = self.environ.get('PATH_INFO', '')
    642641        if not operation:
     
    677676            checkpoint.checkpoint('output as a string')
    678677        except Exception, err:
     678            import traceback
    679679            if not fields.has_key('js'):
    680680                if isinstance(err, CodeError):
    681681                    self.start('500 Internal Server Error', [('Content-Type', 'text/html')])
    682682                    e = revertStandardError()
    683                     s = error(operation, self.username, fields, err, e)
     683                    s = error(operation, self.username, fields,
     684                              err, e, traceback.format_exc())
    684685                    yield str(s)
    685686                    return
     
    690691                    return
    691692            self.start('500 Internal Server Error', [('Content-Type', 'text/plain')])
    692             import traceback
    693693            send_error_mail('xvm error: %s' % (err,),
    694694                            '%s\n' % (traceback.format_exc(),))
  • trunk/packages/sipb-xen-www/code/templates/error.tmpl

    r599 r600  
    1717<pre>
    1818Error on operation $op for user $user: $errorMessage
    19 Error output (if any):
    20 $stderr
     19
     20Fields:
     21#for $f in $fields:
     22$f=$fields[$f].value
     23#end for
     24
     25Error output:
     26$stderr#slurp
     27---- end error output
     28
     29Traceback:
     30$traceback
    2131</pre>
    2232#end def
Note: See TracChangeset for help on using the changeset viewer.