Skip to content

Commit

Permalink
indicate invalid slice if we couldn't turn them into json
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Apr 8, 2024
1 parent 3551d56 commit 338edfc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions attribute/value.go
Expand Up @@ -231,17 +231,26 @@ func (v Value) Emit() string {
case BOOL:
return strconv.FormatBool(v.AsBool())
case INT64SLICE:
j, _ := json.Marshal(v.asInt64Slice())
j, err := json.Marshal(v.asInt64Slice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asInt64Slice())

Check warning on line 236 in attribute/value.go

View check run for this annotation

Codecov / codecov/patch

attribute/value.go#L236

Added line #L236 was not covered by tests
}
return string(j)
case INT64:
return strconv.FormatInt(v.AsInt64(), 10)
case FLOAT64SLICE:
j, _ := json.Marshal(v.asFloat64Slice())
j, err := json.Marshal(v.asFloat64Slice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asFloat64Slice())

Check warning on line 244 in attribute/value.go

View check run for this annotation

Codecov / codecov/patch

attribute/value.go#L244

Added line #L244 was not covered by tests
}
return string(j)
case FLOAT64:
return fmt.Sprint(v.AsFloat64())
case STRINGSLICE:
j, _ := json.Marshal(v.asStringSlice())
j, err := json.Marshal(v.asStringSlice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asStringSlice())

Check warning on line 252 in attribute/value.go

View check run for this annotation

Codecov / codecov/patch

attribute/value.go#L252

Added line #L252 was not covered by tests
}
return string(j)
case STRING:
return v.stringly
Expand Down

0 comments on commit 338edfc

Please sign in to comment.