~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2008-06-25 10:06:48 UTC
  • mfrom: (3509 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3510.
  • Revision ID: mbp@sourcefrog.net-20080625100648-ac20jxcm3ojucuby
merge trunk; remove RemoteToOtherFetcher

Show diffs side-by-side

added added

removed removed

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