Skip to content

Commit 9b8ec9c

Browse files
committed
return :excluded instead of nil
1 parent edd78f8 commit 9b8ec9c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/sentry.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ defmodule Sentry do
111111
@doc """
112112
Parses and submits an exception to Sentry if current environment is in included_environments.
113113
"""
114-
@spec capture_exception(Exception.t, Keyword.t) :: {:ok, String.t} | :error
114+
@spec capture_exception(Exception.t, Keyword.t) :: {:ok, String.t} | :error | :excluded
115115
def capture_exception(exception, opts \\ []) do
116116
filter_module = Application.get_env(:sentry, :filter, Sentry.DefaultEventFilter)
117117
{source, opts} = Keyword.pop(opts, :event_source)
118-
unless(filter_module.exclude_exception?(exception, source)) do
118+
if(filter_module.exclude_exception?(exception, source)) do
119+
:excluded
120+
else
119121
Event.transform_exception(exception, opts)
120122
|> send_event()
121123
end

test/sentry_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule SentryTest do
1818
Application.put_env(:sentry, :included_environments, [:test])
1919
Application.put_env(:sentry, :environment_name, :test)
2020

21-
Sentry.capture_exception(%RuntimeError{message: "error"}, [event_source: :plug])
22-
Sentry.capture_exception(%ArithmeticError{message: "error"}, [event_source: :plug])
21+
assert {:ok, _} = Sentry.capture_exception(%RuntimeError{message: "error"}, [event_source: :plug])
22+
assert :excluded = Sentry.capture_exception(%ArithmeticError{message: "error"}, [event_source: :plug])
2323
end
2424
end

0 commit comments

Comments
 (0)