Skip to content

Commit 8118160

Browse files
committed
better error
1 parent 8ee7f4f commit 8118160

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/plugin/datasource.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataReques
7373
frame.SetMeta(&data.FrameMeta{Channel: channel.String()})
7474
resp.Frames = append(resp.Frames, frame)
7575
} else {
76+
count := 0
7677
columnTypes, ch, err := d.engine.RunQuery(ctx, q.SQL)
7778
if err != nil {
7879
return nil, err
@@ -89,7 +90,7 @@ func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataReques
8990
return nil, ctx.Err()
9091
case row, ok := <-ch:
9192
if !ok {
92-
logger.Info("Query finished")
93+
logger.Info("Query finished", "count", count)
9394

9495
resp.Frames = append(resp.Frames, frame)
9596
break LOOP
@@ -99,6 +100,7 @@ func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataReques
99100
for i, r := range row {
100101
col := columnTypes[i]
101102
fData[i] = timeplus.ParseValue(col.Name(), col.DatabaseTypeName(), nil, r, false)
103+
count++
102104
}
103105

104106
frame.AppendRow(fData...)

pkg/timeplus/engine.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,16 @@ func (e *TimeplusEngine) IsStreamingQuery(ctx context.Context, query string) (bo
150150
}
151151
defer resp.Body.Close()
152152
if resp.StatusCode < 200 || resp.StatusCode > 399 {
153-
return false, fmt.Errorf("failed to analyze %d", resp.StatusCode)
153+
var errStr string
154+
155+
body, err := io.ReadAll(resp.Body)
156+
if err != nil {
157+
errStr = err.Error()
158+
} else {
159+
errStr = string(body)
160+
}
161+
162+
return false, fmt.Errorf("failed to analyze code: %d, error: %s", resp.StatusCode, errStr)
154163
}
155164

156165
body, err := io.ReadAll(resp.Body)

0 commit comments

Comments
 (0)