// CombineErrors returns an error which combined all stored errors.  Return nil
// if not erros stored.
4517
func (d *Drain) CombineErrors() error {
	if d == nil || len(d.errors) == 0 {
		return nil
	}
	return drainError(d.errors)
}
1206535
func (s *BatchDeleteConnectionOutput) SetErrors(v map[string]*ErrorDetail) *BatchDeleteConnectionOutput {
	s.Errors = v
	return s
}
82261
func CombineErrors(delimiter string, errs ...error) error {
	var formatStrs = []string{}

	for _, e := range errs {
		if e == nil {
			continue
		}
		formatStrs = append(formatStrs, e.Error())
	}

	return fmt.Errorf(strings.Join(formatStrs, delimiter))
}
690978
func removeNilErrors(errs []error) []error {
	if len(errs) == 0 {
		return nil
	}
	var r []error
	for _, err := range errs {
		if err != nil {
			r = append(r, err)
		}
	}
	return r
}
467578
func RemoveNilErrors(errs []error) []error {
	var r []error
	for _, err := range errs {
		if err != nil {
			r = append(r, err)
		}
	}
	return r
}
610180
func (s *StatusCheck) Combine(other []byte) error {
	var otherValue float64
	buf := bytes.NewReader(other)
	err := binary.Read(buf, binary.LittleEndian, &otherValue)

	if err != nil {
		return err
	}

	s.Value = otherValue

	return nil
}
805040
func combineHandlers(h1 []Handler, h2 []Handler) []Handler {
	hh := make([]Handler, len(h1)+len(h2))
	copy(hh, h1)
	copy(hh[len(h1):], h2)
	return hh
}
1140643
func (result ErrorResults) Combine() error {
	var errorStrings []string
	for _, r := range result.Results {
		if r.Error != nil {
			errorStrings = append(errorStrings, r.Error.Error())
		}
	}
	if errorStrings != nil {
		return errors.New(strings.Join(errorStrings, "\n"))
	}
	return nil
}
826042
func (s *Update) SetErrors(v []*ErrorDetail) *Update {
	s.Errors = v
	return s
}
362276
func MultipleErrors(prefix string, errs []error) string {
	buf := &bytes.Buffer{}
	for _, err := range errs {
		fmt.Fprintf(buf, "%s%v\n", prefix, messageForError(err))
	}
	return buf.String()
}
75850
func CombineGens(gens ...Gen) Gen {
	return func(genParams *GenParameters) *GenResult {
		labels := []string{}
		values := make([]interface{}, len(gens))
		shrinkers := make([]Shrinker, len(gens))
		sieves := make([]func(v interface{}) bool, len(gens))

		var ok bool
		for i, gen := range gens {
			result := gen(genParams)
			labels = append(labels, result.Labels...)
			shrinkers[i] = result.Shrinker
			sieves[i] = result.Sieve
			values[i], ok = result.Retrieve()
			if !ok {
				return &GenResult{
					Shrinker:   NoShrinker,
					Result:     nil,
					Labels:     result.Labels,
					ResultType: reflect.TypeOf(values),
				}
			}
		}
		return &GenResult{
			Shrinker:   CombineShrinker(shrinkers...),
			Result:     values,
			Labels:     labels,
			ResultType: reflect.TypeOf(values),
			Sieve: func(v interface{}) bool {
				values := v.([]interface{})
				for i, value := range values {
					if sieves[i] != nil && !sieves[i](value) {
						return false
					}
				}
				return true
			},
		}
	}
}
271218
func CombineFields(s []Field) string {
	r := make([]string, len(s))
	for i, v := range s {
		r[i] = string(v)
	}
	return strings.Join(r, ",")
}
692173
func (errs Errors) Error() string {
	if len(errs) == 0 {
		return ""
	}
	if len(errs) == 1 {
		return errs[0].Error()
	}

	errors := []string{fmt.Sprint("Multiple errors occurred:")}
	for _, err := range errs {
		errors = append(errors, err.Error())
	}
	return strings.Join(errors, " - ")
}
1121409
func MultiErrorAppend(err error, errs ...error) *MultiError {
	if err == nil {
		err = new(MultiError)
	}

	switch err := err.(type) {
	case *MultiError:
		if err == nil {
			err = new(MultiError)
		}

		for _, verr := range errs {
			switch rhsErr := verr.(type) {
			case *MultiError:
				if rhsErr != nil {
					err.Errors = append(err.Errors, rhsErr.Errors...)
				}
			default:
				err.Errors = append(err.Errors, verr)
			}
		}
		return err
	default:
		newErrs := make([]error, len(errs)+1)
		newErrs[0] = err
		copy(newErrs[1:], errs)
		return &MultiError{
			Errors: newErrs,
		}
	}
}
310799
func (diags Diagnostics) HasErrors() bool {
	for _, diag := range diags {
		if diag.Severity() == Error {
			return true
		}
	}
	return false
}
715055
func (r *Result) withError(err error) *Result {
	r.err = err
	return r
}
1098245
func (ec *ErrorCollection) addError(err error) {
	if ec.DuplicatationOptions != AllowDuplicates {
		//Don't append if err is a duplicate
		for i, containedErr := range ec.Errors {

			var je1 *JE
			var je2 *JE

			s, ok := err.(JE)
			if ok {
				je1 = &s
			} else {
				s, ok := err.(*JE)
				if ok {
					je1 = s
				}
			}

			_, ok = containedErr.(JE)
			if ok {
				t := (ec.Errors[i]).(JE)
				je2 = &t
			} else {
				_, ok := containedErr.(*JE)
				if ok {
					je2 = (ec.Errors[i]).(*JE)
				}
			}

			if je1 != nil && je2 != nil {
				//Don't use Reflection since both are JE structs
				if (*je1).Code == (*je2).Code && (*je1).Domain == (*je2).Domain && (*je1).error == (*je2).error && (*je1).message == (*je2).message {
					if ec.DuplicatationOptions == RejectDuplicates {
						if (*je1).time.Equal((*je2).time) {
							//Both JE structs are 100% identical including timestamp
							return
						}
					} else {
						//We don't care about timestamps
						return
					}
				}
			} else {
				//Use Reflection
				if reflect.DeepEqual(containedErr, err) {
					return
				}
			}
		}
	}
	ec.Errors = append(ec.Errors, err)
}