~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

[merge] aaron, various fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
    exc_info - typically an exception from sys.exc_info()
239
239
    """
240
240
    exc_type, exc_object, exc_tb = exc_info
241
 
    if exc_type is None:
242
 
        return '(no exception)'
243
 
    if isinstance(exc_object, BzrNewError):
244
 
        return str(exc_object)
245
 
    else:
246
 
        import traceback
247
 
        tb = traceback.extract_tb(exc_tb)
248
 
        msg = '%s: %s' % (exc_type, exc_object)
249
 
        if msg[-1] == '\n':
250
 
            msg = msg[:-1]
251
 
        if tb:
252
 
            msg += '\n  at %s line %d\n  in %s' % (tb[-1][:3])
253
 
        return msg
 
241
    try:
 
242
        if exc_type is None:
 
243
            return '(no exception)'
 
244
        if isinstance(exc_object, BzrNewError):
 
245
            return str(exc_object)
 
246
        else:
 
247
            import traceback
 
248
            tb = traceback.extract_tb(exc_tb)
 
249
            msg = '%s: %s' % (exc_type, exc_object)
 
250
            if msg[-1] == '\n':
 
251
                msg = msg[:-1]
 
252
            if tb:
 
253
                msg += '\n  at %s line %d\n  in %s' % (tb[-1][:3])
 
254
            return msg
 
255
    except:
 
256
        return '(error formatting exception of type %s)' % exc_type