use AddError everywhere (#2372)

This commit is contained in:
Patrick Hemmer
2017-04-24 14:13:26 -04:00
committed by Daniel Nelson
parent 801f6cb8a0
commit 06baf7cf78
95 changed files with 341 additions and 531 deletions

View File

@@ -154,15 +154,16 @@ func (l *LeoFS) Gather(acc telegraf.Accumulator) error {
return nil
}
var wg sync.WaitGroup
var outerr error
for _, endpoint := range l.Servers {
_, err := url.Parse(endpoint)
if err != nil {
return fmt.Errorf("Unable to parse the address:%s, err:%s", endpoint, err)
acc.AddError(fmt.Errorf("Unable to parse the address:%s, err:%s", endpoint, err))
continue
}
port, err := retrieveTokenAfterColon(endpoint)
if err != nil {
return err
acc.AddError(err)
continue
}
st, ok := serverTypeMapping[port]
if !ok {
@@ -171,11 +172,11 @@ func (l *LeoFS) Gather(acc telegraf.Accumulator) error {
wg.Add(1)
go func(endpoint string, st ServerType) {
defer wg.Done()
outerr = l.gatherServer(endpoint, st, acc)
acc.AddError(l.gatherServer(endpoint, st, acc))
}(endpoint, st)
}
wg.Wait()
return outerr
return nil
}
func (l *LeoFS) gatherServer(

View File

@@ -146,7 +146,7 @@ func testMain(t *testing.T, code string, endpoint string, serverType ServerType)
var acc testutil.Accumulator
acc.SetDebug(true)
err := l.Gather(&acc)
err := acc.GatherError(l.Gather)
require.NoError(t, err)
floatMetrics := KeyMapping[serverType]