Skip to content

Commit

Permalink
accept nil EventModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
rerorero committed Oct 24, 2019
1 parent 77ad23b commit e153f00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
}},
}

if scope == nil {
return event
}

event = scope.ApplyToEvent(event, hint)

for _, processor := range client.eventProcessors {
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 e153f00

Please sign in to comment.