From 47345944882cefbc2608a20be0e660486b6fb790 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, 9 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 2465bb36d..5ffc30401 100644 --- a/client.go +++ b/client.go @@ -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 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)