~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

Merge from mbp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
import logging
46
46
 
47
47
import bzrlib
48
 
from bzrlib.errors import BzrNewError
 
48
from bzrlib.errors import BzrError, BzrNewError
49
49
 
50
50
 
51
51
_file_handler = None
54
54
_trace_file = None
55
55
_bzr_log_file = None
56
56
 
 
57
 
57
58
class QuietFormatter(logging.Formatter):
58
59
    """Formatter that supresses the details of errors.
59
60
 
252
253
    try:
253
254
        if exc_type is None:
254
255
            return '(no exception)'
255
 
        if isinstance(exc_object, BzrNewError):
 
256
        if isinstance(exc_object, (BzrError, BzrNewError)):
256
257
            return str(exc_object)
257
258
        else:
258
259
            import traceback
263
264
            if tb:
264
265
                msg += '\n  at %s line %d\n  in %s' % (tb[-1][:3])
265
266
            return msg
266
 
    except:
267
 
        return '(error formatting exception of type %s)' % exc_type
 
267
    except Exception, formatting_exc:
 
268
        # XXX: is this really better than just letting it run up?
 
269
        return '(error formatting exception of type %s: %s)' \
 
270
                % (exc_type, formatting_exc)