/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Robert Collins
  • Date: 2007-10-03 06:15:06 UTC
  • mfrom: (2879 +trunk)
  • mto: (2592.3.161 repository)
  • mto: This revision was merged to the branch mainline in revision 2880.
  • Revision ID: robertc@robertcollins.net-20071003061506-2hbze42e1sokni8j
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
lazy_import(globals(), """
69
69
from bzrlib import (
70
70
    debug,
 
71
    errors,
71
72
    osutils,
72
73
    plugin,
73
74
    )
312
313
 
313
314
 
314
315
def report_exception(exc_info, err_file):
 
316
    """Report an exception to err_file (typically stderr) and to .bzr.log.
 
317
 
 
318
    This will show either a full traceback or a short message as appropriate.
 
319
 
 
320
    :return: The appropriate exit code for this error.
 
321
    """
315
322
    exc_type, exc_object, exc_tb = exc_info
316
323
    # Log the full traceback to ~/.bzr.log
317
324
    log_exception_quietly()
318
325
    if (isinstance(exc_object, IOError)
319
326
        and getattr(exc_object, 'errno', None) == errno.EPIPE):
320
327
        print >>err_file, "bzr: broken pipe"
 
328
        return errors.EXIT_ERROR
321
329
    elif isinstance(exc_object, KeyboardInterrupt):
322
330
        print >>err_file, "bzr: interrupted"
 
331
        return errors.EXIT_ERROR
323
332
    elif not getattr(exc_object, 'internal_error', True):
324
333
        report_user_error(exc_info, err_file)
 
334
        return errors.EXIT_ERROR
325
335
    elif isinstance(exc_object, (OSError, IOError)):
326
336
        # Might be nice to catch all of these and show them as something more
327
337
        # specific, but there are too many cases at the moment.
328
338
        report_user_error(exc_info, err_file)
 
339
        return errors.EXIT_ERROR
329
340
    else:
330
341
        report_bug(exc_info, err_file)
 
342
        return errors.EXIT_INTERNAL_ERROR
331
343
 
332
344
 
333
345
# TODO: Should these be specially encoding the output?