plugins: map error property on query result

This commit is contained in:
bergquist 2018-01-24 10:37:04 +01:00
parent ee973a977b
commit 6a6eab5ea1

View File

@ -2,6 +2,7 @@ package wrapper
import (
"context"
"errors"
"fmt"
"github.com/grafana/grafana/pkg/components/null"
@ -67,9 +68,11 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
}
for _, r := range pbres.Results {
res.Results[r.RefId] = &tsdb.QueryResult{
RefId: r.RefId,
Series: []*tsdb.TimeSeries{},
qr := &tsdb.QueryResult{
RefId: r.RefId,
Series: []*tsdb.TimeSeries{},
Error: errors.New(r.Error),
ErrorString: r.Error,
}
for _, s := range r.GetSeries() {
@ -80,7 +83,7 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
points = append(points, po)
}
res.Results[r.RefId].Series = append(res.Results[r.RefId].Series, &tsdb.TimeSeries{
qr.Series = append(qr.Series, &tsdb.TimeSeries{
Name: s.Name,
Tags: s.Tags,
Points: points,
@ -91,7 +94,9 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
if err != nil {
return nil, err
}
res.Results[r.RefId].Tables = mappedTables
qr.Tables = mappedTables
res.Results[r.RefId] = qr
}
return res, nil