Skip to content

Commit 5a42bb6

Browse files
committed
return error appended frame
1 parent 5cf79dc commit 5a42bb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/plugin/message.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package plugin
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"sort"
67
"strconv"
78
"strings"
@@ -44,7 +45,11 @@ func jsonMessagesToFrame(topic string, messages []mqtt.Message) *data.Frame {
4445
var body map[string]float64
4546
err := json.Unmarshal([]byte(messages[0].Value), &body)
4647
if err != nil {
47-
return nil // TODO error? frame with error????
48+
frame := data.NewFrame(topic)
49+
frame.AppendNotices(data.Notice{Severity: data.NoticeSeverityError,
50+
Text: fmt.Sprintf("error unmarshalling json message: %s", err.Error()),
51+
})
52+
return frame
4853
}
4954

5055
timeField := data.NewFieldFromFieldType(data.FieldTypeTime, count)

0 commit comments

Comments
 (0)