<commit_before>package network

import (
	"strings"
	"time"

	"github.com/scrapli/scrapligo/driver/base"
)

// SendConfig send configuration string to the device.
func (d *Driver) SendConfig(c string, o ...base.SendOption) (*base.Response, error) {
	sc := strings.Split(c, "\n")
	m, err := d.SendConfigs(sc, o...)

	r := base.NewResponse(
		d.Host,
		d.Transport.BaseTransportArgs.Port,
		c,
		m.Responses[0].FailedWhenContains,
	)

	if err != nil {
		return r, err
	}

	individualResponses := make([]string, len(sc))
	for _, response := range m.Responses {
		individualResponses = append(individualResponses, response.Result)
	}

	r.StartTime = m.StartTime
	r.EndTime = time.Now()
	r.ElapsedTime = r.EndTime.Sub(r.StartTime).Seconds()
	r.Result = strings.Join(individualResponses, "\n")

	return r, nil
}
<commit_msg>dont build response until after checking sendconfigs err<commit_after>package network

import (
	"strings"
	"time"

	"github.com/scrapli/scrapligo/driver/base"
)

// SendConfig send configuration string to the device.
func (d *Driver) SendConfig(c string, o ...base.SendOption) (*base.Response, error) {
	sc := strings.Split(c, "\n")
	m, err := d.SendConfigs(sc, o...)

	if err != nil {
		return nil, err
	}

	r := base.NewResponse(
		d.Host,
		d.Transport.BaseTransportArgs.Port,
		c,
		m.Responses[0].FailedWhenContains,
	)

	individualResponses := make([]string, len(sc))
	for _, response := range m.Responses {
		individualResponses = append(individualResponses, response.Result)
	}

	r.StartTime = m.StartTime
	r.EndTime = time.Now()
	r.ElapsedTime = r.EndTime.Sub(r.StartTime).Seconds()
	r.Result = strings.Join(individualResponses, "\n")

	return r, nil
}

{'fraction_non_alphanumeric': 0.148720999405116, 'fraction_numerical': 0.001189767995240928, 'mean_word_length': 4.066265060240964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6173235', 'n_tokens_mistral': 649, 'n_tokens_neox': 610, 'n_words': 133}