diff --git a/component/componenterror/errors.go b/component/componenterror/errors.go index c4b7f4ddfbea..ecc8c6a1f1f7 100644 --- a/component/componenterror/errors.go +++ b/component/componenterror/errors.go @@ -18,8 +18,6 @@ package componenterror import ( "errors" - "fmt" - "strings" "go.opentelemetry.io/collector/consumer/consumererror" ) @@ -38,27 +36,5 @@ var ( // CombineErrors converts a list of errors into one error. // Deprecated: use consumererror.CombineErrors instead. func CombineErrors(errs []error) error { - numErrors := len(errs) - if numErrors == 0 { - // No errors - return nil - } - - if numErrors == 1 { - return errs[0] - } - - errMsgs := make([]string, 0, numErrors) - permanent := false - for _, err := range errs { - if !permanent && consumererror.IsPermanent(err) { - permanent = true - } - errMsgs = append(errMsgs, err.Error()) - } - err := fmt.Errorf("[%s]", strings.Join(errMsgs, "; ")) - if permanent { - err = consumererror.Permanent(err) - } - return err + return consumererror.CombineErrors(errs) } diff --git a/component/componenterror/errors_test.go b/component/componenterror/errors_test.go deleted file mode 100644 index c0c7b8e7bd85..000000000000 --- a/component/componenterror/errors_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package componenterror_test - -import ( - "fmt" - "testing" - - "go.opentelemetry.io/collector/component/componenterror" - "go.opentelemetry.io/collector/consumer/consumererror" -) - -func TestCombineErrors(t *testing.T) { - testCases := []struct { - errors []error - expected string - expectNil bool - expectedPermanent bool - }{ - { - errors: []error{}, - expectNil: true, - }, - { - errors: []error{ - fmt.Errorf("foo"), - }, - expected: "foo", - }, - { - errors: []error{ - fmt.Errorf("foo"), - fmt.Errorf("bar"), - }, - expected: "[foo; bar]", - }, - { - errors: []error{ - fmt.Errorf("foo"), - fmt.Errorf("bar"), - consumererror.Permanent(fmt.Errorf("permanent"))}, - expected: "Permanent error: [foo; bar; Permanent error: permanent]", - }, - } - - for _, tc := range testCases { - got := componenterror.CombineErrors(tc.errors) - if (got == nil) != tc.expectNil { - t.Errorf("CombineErrors(%v) == nil? Got: %t. Want: %t", tc.errors, got == nil, tc.expectNil) - } - if got != nil && tc.expected != got.Error() { - t.Errorf("CombineErrors(%v) = %q. Want: %q", tc.errors, got, tc.expected) - } - if tc.expectedPermanent && !consumererror.IsPermanent(got) { - t.Errorf("CombineErrors(%v) = %q. Want: consumererror.permanent", tc.errors, got) - } - } -} diff --git a/consumer/consumererror/combineerrors.go b/consumer/consumererror/combineerrors.go index 54bbf86f5af1..1010c07d60c8 100644 --- a/consumer/consumererror/combineerrors.go +++ b/consumer/consumererror/combineerrors.go @@ -20,8 +20,6 @@ import ( ) // CombineErrors converts a list of errors into one error. -// -// TODO: deprecate componenterror.CombineErrors in favor of this function. func CombineErrors(errs []error) error { numErrors := len(errs) if numErrors == 0 {