Skip to content

Commit

Permalink
fix: accept nil EventModifier (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
rerorero authored and kamilogorek committed Nov 12, 2019
1 parent f6c52c0 commit 7f0ce8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
}},
}

event = scope.ApplyToEvent(event, hint)
if scope != nil {
event = scope.ApplyToEvent(event, hint)
}

for _, processor := range client.eventProcessors {
id := event.EventID
Expand Down
6 changes: 6 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ func TestCaptureMessageShouldSendEventWithProvidedMessage(t *testing.T) {
assertEqual(t, transport.lastEvent.Message, "foo")
}

func TestCaptureMessageShouldSucceedWithoutNilScope(t *testing.T) {
client, _, transport := setupClientTest()
client.CaptureMessage("foo", nil, nil)
assertEqual(t, transport.lastEvent.Message, "foo")
}

func TestCaptureExceptionShouldSendEventWithProvidedError(t *testing.T) {
client, scope, transport := setupClientTest()
client.CaptureException(errors.New("custom error"), nil, scope)
Expand Down

0 comments on commit 7f0ce8a

Please sign in to comment.