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

@@ -170,7 +170,8 @@ func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
if p.Query[i].Version <= db_version {
rows, err := db.Query(sql_query)
if err != nil {
return err
acc.AddError(err)
continue
}
defer rows.Close()
@@ -178,7 +179,8 @@ func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
// grab the column information from the result
p.OrderedColumns, err = rows.Columns()
if err != nil {
return err
acc.AddError(err)
continue
} else {
for _, v := range p.OrderedColumns {
p.AllColumns = append(p.AllColumns, v)
@@ -195,7 +197,8 @@ func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
for rows.Next() {
err = p.accRow(meas_name, rows, acc)
if err != nil {
return err
acc.AddError(err)
break
}
}
}

View File

@@ -26,7 +26,7 @@ func TestPostgresqlGeneratesMetrics(t *testing.T) {
},
}
var acc testutil.Accumulator
err := p.Gather(&acc)
err := acc.GatherError(p.Gather)
require.NoError(t, err)
availableColumns := make(map[string]bool)
@@ -114,7 +114,7 @@ func TestPostgresqlIgnoresUnwantedColumns(t *testing.T) {
var acc testutil.Accumulator
err := p.Gather(&acc)
err := acc.GatherError(p.Gather)
require.NoError(t, err)
for col := range p.IgnoredColumns() {