Skip to content

Commit 565c87f

Browse files
committed
indicate invalid slice if we couldn't turn them into json
1 parent c7ef823 commit 565c87f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

attribute/value.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,26 @@ func (v Value) Emit() string {
231231
case BOOL:
232232
return strconv.FormatBool(v.AsBool())
233233
case INT64SLICE:
234-
j, _ := json.Marshal(v.asInt64Slice())
234+
j, err := json.Marshal(v.asInt64Slice())
235+
if err != nil {
236+
return fmt.Sprintf("invalid: %v", v.asInt64Slice())
237+
}
235238
return string(j)
236239
case INT64:
237240
return strconv.FormatInt(v.AsInt64(), 10)
238241
case FLOAT64SLICE:
239-
j, _ := json.Marshal(v.asFloat64Slice())
242+
j, err := json.Marshal(v.asFloat64Slice())
243+
if err != nil {
244+
return fmt.Sprintf("invalid: %v", v.asFloat64Slice())
245+
}
240246
return string(j)
241247
case FLOAT64:
242248
return fmt.Sprint(v.AsFloat64())
243249
case STRINGSLICE:
244-
j, _ := json.Marshal(v.asStringSlice())
250+
j, err := json.Marshal(v.asStringSlice())
251+
if err != nil {
252+
return fmt.Sprintf("invalid: %v", v.asStringSlice())
253+
}
245254
return string(j)
246255
case STRING:
247256
return v.stringly

0 commit comments

Comments
 (0)