This repository was archived by the owner on Nov 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515package processor
1616
1717import (
18- "fmt"
19- "strings"
18+ "github.com/census-instrumentation/opencensus-service/internal"
2019
2120 "github.com/spf13/cast"
2221
@@ -124,18 +123,5 @@ func (msp *multiSpanProcessor) ProcessSpans(batch *agenttracepb.ExportTraceServi
124123 maxFailures = failures
125124 }
126125 }
127-
128- var err error
129- numErrors := len (errors )
130- if numErrors == 1 {
131- err = errors [0 ]
132- } else if numErrors > 1 {
133- errMsgs := make ([]string , numErrors )
134- for _ , err := range errors {
135- errMsgs = append (errMsgs , err .Error ())
136- }
137- err = fmt .Errorf ("[%s]" , strings .Join (errMsgs , "; " ))
138- }
139-
140- return maxFailures , err
126+ return maxFailures , internal .CombineErrors (errors )
141127}
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ package internal
1616
1717import (
1818 "encoding/json"
19- "errors"
2019 "fmt"
2120 "io/ioutil"
2221 "os"
@@ -102,14 +101,15 @@ func TimeToTimestamp(t time.Time) *timestamp.Timestamp {
102101
103102// CombineErrors converts a list of errors into one error.
104103func CombineErrors (errs []error ) error {
105- if len (errs ) == 0 {
106- return nil
107- }
108-
109- // Otherwise
110- buf := new (strings.Builder )
111- for _ , err := range errs {
112- fmt .Fprintf (buf , "%v\n " , err )
104+ numErrors := len (errs )
105+ if numErrors == 1 {
106+ return errs [0 ]
107+ } else if numErrors > 1 {
108+ errMsgs := make ([]string , numErrors )
109+ for _ , err := range errs {
110+ errMsgs = append (errMsgs , err .Error ())
111+ }
112+ return fmt .Errorf ("[%s]" , strings .Join (errMsgs , "; " ))
113113 }
114- return errors . New ( buf . String ())
114+ return nil
115115}
You can’t perform that action at this time.
0 commit comments