~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

MergeĀ fromĀ old-hpss-branch-implementation-test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
    elif isinstance(exc_object, KeyboardInterrupt):
406
406
        err_file.write("bzr: interrupted\n")
407
407
        return errors.EXIT_ERROR
 
408
    elif isinstance(exc_object, ImportError) \
 
409
        and str(exc_object).startswith("No module named "):
 
410
        report_user_error(exc_info, err_file,
 
411
            'You may need to install this Python library separately.')
 
412
        return errors.EXIT_ERROR
408
413
    elif not getattr(exc_object, 'internal_error', True):
409
414
        report_user_error(exc_info, err_file)
410
415
        return errors.EXIT_ERROR
427
432
 
428
433
 
429
434
# TODO: Should these be specially encoding the output?
430
 
def report_user_error(exc_info, err_file):
 
435
def report_user_error(exc_info, err_file, advice=None):
431
436
    """Report to err_file an error that's not an internal error.
432
437
 
433
438
    These don't get a traceback unless -Derror was given.
 
439
 
 
440
    :param exc_info: 3-tuple from sys.exc_info()
 
441
    :param advice: Extra advice to the user to be printed following the
 
442
        exception.
434
443
    """
435
444
    if 'error' in debug.debug_flags:
436
445
        print_exception(exc_info, err_file)
437
446
        return
438
447
    err_file.write("bzr: ERROR: %s\n" % (exc_info[1],))
 
448
    if advice:
 
449
        err_file.write("%s\n" % (advice,))
439
450
 
440
451
 
441
452
def report_bug(exc_info, err_file):