use AddError everywhere (#2372)
This commit is contained in:
committed by
Daniel Nelson
parent
801f6cb8a0
commit
06baf7cf78
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user