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

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"regexp"
"strconv"
"strings"
@@ -159,7 +158,7 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
// Get daemon info
err := d.gatherInfo(acc)
if err != nil {
fmt.Println(err.Error())
acc.AddError(err)
}
// List containers
@@ -179,8 +178,8 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
defer wg.Done()
err := d.gatherContainer(c, acc)
if err != nil {
log.Printf("E! Error gathering container %s stats: %s\n",
c.Names, err.Error())
acc.AddError(fmt.Errorf("E! Error gathering container %s stats: %s\n",
c.Names, err.Error()))
}
}(container)
}

View File

@@ -302,7 +302,7 @@ func TestDockerGatherInfo(t *testing.T) {
testing: true,
}
err := d.Gather(&acc)
err := acc.GatherError(d.Gather)
require.NoError(t, err)
acc.AssertContainsTaggedFields(t,