def assign_exit_code(opt_succeeded, gulp_errors, parser_errors,
    single_point_only):
    """ given the error messages, assign an exit code """
    if '**** Too many failed attempts to optimise ****' in gulp_errors:
        return 'ERROR_OPTIMISE_MAX_ATTEMPTS'
    elif '**** Maximum number of function calls has been reached ****' in gulp_errors:
        return 'ERROR_OPTIMISE_MAX_CALLS'
    elif opt_succeeded is False and not single_point_only:
        return 'ERROR_OPTIMISE_UNSUCCESFUL'
    elif gulp_errors:
        return 'ERROR_GULP_UNHANDLED'
    elif parser_errors:
        return 'ERROR_PARSING_STDOUT'
    elif opt_succeeded is None and not single_point_only:
        return 'ERROR_GULP_UNHANDLED'
    return None
