예제 #1
0
def report_exception(exc_info, err_file):
    """Report an exception to err_file (typically stderr) and to .bzr.log.

    This will show either a full traceback or a short message as appropriate.

    :return: The appropriate exit code for this error.
    """
    # Log the full traceback to ~/.bzr.log
    log_exception_quietly()
    if 'error' in debug.debug_flags:
        print_exception(exc_info, err_file)
        return errors.EXIT_ERROR
    exc_type, exc_object, exc_tb = exc_info
    if isinstance(exc_object, KeyboardInterrupt):
        err_file.write("bzr: interrupted\n")
        return errors.EXIT_ERROR
    elif isinstance(exc_object, MemoryError):
        err_file.write("bzr: out of memory\n")
        if 'mem_dump' in debug.debug_flags:
            _dump_memory_usage(err_file)
        else:
            err_file.write("Use -Dmem_dump to dump memory to a file.\n")
        return errors.EXIT_ERROR
    elif isinstance(exc_object, ImportError) \
        and str(exc_object).startswith("No module named "):
        report_user_error(
            exc_info, err_file,
            'You may need to install this Python library separately.')
        return errors.EXIT_ERROR
    elif not getattr(exc_object, 'internal_error', True):
        report_user_error(exc_info, err_file)
        return errors.EXIT_ERROR
    elif osutils.is_environment_error(exc_object):
        if getattr(exc_object, 'errno', None) == errno.EPIPE:
            err_file.write("bzr: broken pipe\n")
            return errors.EXIT_ERROR
        # Might be nice to catch all of these and show them as something more
        # specific, but there are too many cases at the moment.
        report_user_error(exc_info, err_file)
        return errors.EXIT_ERROR
    else:
        report_bug(exc_info, err_file)
        return errors.EXIT_INTERNAL_ERROR
예제 #2
0
def report_exception(exc_info, err_file):
    """Report an exception to err_file (typically stderr) and to .bzr.log.

    This will show either a full traceback or a short message as appropriate.

    :return: The appropriate exit code for this error.
    """
    # Log the full traceback to ~/.bzr.log
    log_exception_quietly()
    if 'error' in debug.debug_flags:
        print_exception(exc_info, err_file)
        return errors.EXIT_ERROR
    exc_type, exc_object, exc_tb = exc_info
    if isinstance(exc_object, KeyboardInterrupt):
        err_file.write("bzr: interrupted\n")
        return errors.EXIT_ERROR
    elif isinstance(exc_object, MemoryError):
        err_file.write("bzr: out of memory\n")
        if 'mem_dump' in debug.debug_flags:
            _dump_memory_usage(err_file)
        else:
            err_file.write("Use -Dmem_dump to dump memory to a file.\n")
        return errors.EXIT_ERROR
    elif isinstance(exc_object, ImportError) \
        and str(exc_object).startswith("No module named "):
        report_user_error(exc_info, err_file,
            'You may need to install this Python library separately.')
        return errors.EXIT_ERROR
    elif not getattr(exc_object, 'internal_error', True):
        report_user_error(exc_info, err_file)
        return errors.EXIT_ERROR
    elif osutils.is_environment_error(exc_object):
        if getattr(exc_object, 'errno', None) == errno.EPIPE:
            err_file.write("bzr: broken pipe\n")
            return errors.EXIT_ERROR
        # Might be nice to catch all of these and show them as something more
        # specific, but there are too many cases at the moment.
        report_user_error(exc_info, err_file)
        return errors.EXIT_ERROR
    else:
        report_bug(exc_info, err_file)
        return errors.EXIT_INTERNAL_ERROR
예제 #3
0
def report_bug(exc_info, err_file):
    """Report an exception that probably indicates a bug in bzr"""
    from bzrlib.crash import report_bug
    report_bug(exc_info, err_file)
예제 #4
0
def report_bug(exc_info, err_file):
    """Report an exception that probably indicates a bug in bzr"""
    from bzrlib.crash import report_bug
    report_bug(exc_info, err_file)