Browse Source

plugins: map error property on query result

bergquist 8 years ago
parent
commit
6a6eab5ea1
1 changed files with 10 additions and 5 deletions
  1. 10 5
      pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go

+ 10 - 5
pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go

@@ -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