Skip to content

Commit

Permalink
chore: correct error returned on failure to parse JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-svensson committed Feb 10, 2024
1 parent 9f2d061 commit 0941f9b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TypeMappingHandler(handler Handler) EventHandler[json.RawMessage] {
return ErrNoMessageTypeForRouteKey
}
if err := json.Unmarshal(event.Payload, &message); err != nil {
return err
return fmt.Errorf("%v: %w", err, ErrParseJSON)
}
msg := ConsumableEvent[any]{
Metadata: event.Metadata,
Expand Down
2 changes: 1 addition & 1 deletion setup_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func Test_TypeMappingHandler(t *testing.T) {
},
},
wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
return assert.EqualError(t, err, "unexpected end of JSON input")
return assert.ErrorContains(t, err, "unexpected end of JSON input")
},
},
{
Expand Down

0 comments on commit 0941f9b

Please sign in to comment.