~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-05 11:32:59 UTC
  • mfrom: (6336.2.3 is_environment_error)
  • Revision ID: pqm@pqm.ubuntu.com-20111205113259-ias55e1z6dsn2ksp
(gz) Add is_environment_error() to check if exceptions are due to the
 process environment (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
491
491
        print_exception(exc_info, err_file)
492
492
        return errors.EXIT_ERROR
493
493
    exc_type, exc_object, exc_tb = exc_info
494
 
    if (isinstance(exc_object, IOError)
495
 
        and getattr(exc_object, 'errno', None) == errno.EPIPE):
496
 
        err_file.write("bzr: broken pipe\n")
497
 
        return errors.EXIT_ERROR
498
 
    elif isinstance(exc_object, KeyboardInterrupt):
 
494
    if isinstance(exc_object, KeyboardInterrupt):
499
495
        err_file.write("bzr: interrupted\n")
500
496
        return errors.EXIT_ERROR
501
497
    elif isinstance(exc_object, MemoryError):
513
509
    elif not getattr(exc_object, 'internal_error', True):
514
510
        report_user_error(exc_info, err_file)
515
511
        return errors.EXIT_ERROR
516
 
    elif isinstance(exc_object, (OSError, IOError)) or (
517
 
        # GZ 2010-05-20: Like (exc_type is pywintypes.error) but avoid import
518
 
        exc_type.__name__ == "error" and exc_type.__module__ == "pywintypes"):
 
512
    elif osutils.is_environment_error(exc_object):
 
513
        if getattr(exc_object, 'errno', None) == errno.EPIPE:
 
514
            err_file.write("bzr: broken pipe\n")
 
515
            return errors.EXIT_ERROR
519
516
        # Might be nice to catch all of these and show them as something more
520
517
        # specific, but there are too many cases at the moment.
521
518
        report_user_error(exc_info, err_file)