Skip to content

Commit

Permalink
Don't error if we encounter an unknown msg
Browse files Browse the repository at this point in the history
  • Loading branch information
bahlo authored and lukasmalkmus committed Aug 18, 2021
1 parent 53a3acf commit 1b9df8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
15 changes: 10 additions & 5 deletions axiom/query/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ type MessageCode uint8

// All available message codes.
const (
VirtualFieldFinalizeError MessageCode = iota + 1 // virtual_field_finalize_error
MissingColumn // missing_column
LicenseLimitForQueryWarning // license_limit_for_query_warning
DefaultLimitWarning // default_limit_warning
UnknownMessageCode MessageCode = iota
VirtualFieldFinalizeError // virtual_field_finalize_error
MissingColumn // missing_column
LicenseLimitForQueryWarning // license_limit_for_query_warning
DefaultLimitWarning // default_limit_warning
)

// UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the
Expand All @@ -32,8 +33,12 @@ func (mc *MessageCode) UnmarshalJSON(b []byte) error {
*mc = VirtualFieldFinalizeError
case MissingColumn.String():
*mc = MissingColumn
case LicenseLimitForQueryWarning.String():
*mc = LicenseLimitForQueryWarning
case DefaultLimitWarning.String():
*mc = DefaultLimitWarning
default:
return fmt.Errorf("unknown message code %q", s)
*mc = UnknownMessageCode
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions axiom/query/result_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions axiom/query/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func TestMessageCode_Unmarshal(t *testing.T) {

func TestMessageCode_String(t *testing.T) {
// Check outer bounds.
assert.Equal(t, MessageCode(0).String(), "MessageCode(0)")
assert.Contains(t, (VirtualFieldFinalizeError - 1).String(), "MessageCode(")
assert.Contains(t, (DefaultLimitWarning + 1).String(), "MessageCode(")

for typ := VirtualFieldFinalizeError; typ <= DefaultLimitWarning; typ++ {
Expand Down

0 comments on commit 1b9df8b

Please sign in to comment.