From e153f00c5f76282160f38f0c9d7f4cd148dfb7fe Mon Sep 17 00:00:00 2001 From: rerorero Date: Thu, 24 Oct 2019 16:12:12 +0900 Subject: [PATCH] accept nil EventModifier --- client.go | 4 ++++ client_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/client.go b/client.go index 2465bb36d..89fad84aa 100644 --- a/client.go +++ b/client.go @@ -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 { diff --git a/client_test.go b/client_test.go index 7f132ea60..252759711 100644 --- a/client_test.go +++ b/client_test.go @@ -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)