Skip to content

Commit 048836c

Browse files
Merge pull request #111 from Ebtoulson/master
fix documentation around exception filtering
2 parents 4f05ac1 + 28594c3 commit 048836c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

docs/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ new process and it fails you might lose your context. That said using the contex
110110
Filtering Events
111111
----------------
112112

113-
If you would like to prevent certain exceptions, the :filter configuration option
113+
If you would like to prevent certain exceptions, the ``:filter`` configuration option
114114
allows you to implement the ``Sentry.EventFilter`` behaviour. The first argument is the
115-
source of the event, and the second is the exception to be sent. ``Sentry.Plug``
115+
exception to be sent, and the second is the source of the event. ``Sentry.Plug``
116116
will have a source of ``:plug``, and ``Sentry.Logger`` will have a source of ``:logger``.
117117
If an exception does not come from either of those sources, the source will be nil
118118
unless the ``:event_source`` option is passed to ``Sentry.capture_exception/2``
@@ -122,12 +122,12 @@ allows other exceptions to be sent.
122122

123123
.. code-block:: elixir
124124
125-
# sentry_event_filter.exs
125+
# sentry_event_filter.ex
126126
defmodule MyApp.SentryEventFilter do
127127
@behaviour Sentry.EventFilter
128128
129-
def exclude_exception?(:plug, %Elixir.Phoenix.Router.NoRouteError{}), do: true
130-
def exclude_exception?(_, ), do: false
129+
def exclude_exception?(%Elixir.Phoenix.Router.NoRouteError{}, :plug), do: true
130+
def exclude_exception?(_exception, _source), do: false
131131
end
132132
133133
# config.exs

lib/sentry.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ defmodule Sentry do
5353
5454
## Filtering Exceptions
5555
56-
If you would like to prevent certain exceptions, the :filter configuration option
56+
If you would like to prevent certain exceptions, the `:filter` configuration option
5757
allows you to implement the `Sentry.EventFilter` behaviour. The first argument is the
58-
source of the event, and the second is the exception to be sent. `Sentry.Plug`
58+
exception to be sent, and the second is the source of the event. `Sentry.Plug`
5959
will have a source of `:plug`, and `Sentry.Logger` will have a source of `:logger`.
6060
If an exception does not come from either of those sources, the source will be nil
6161
unless the `:event_source` option is passed to `Sentry.capture_exception/2`
6262
6363
A configuration like below will prevent sending `Phoenix.Router.NoRouteError` from `Sentry.Plug`, but
6464
allows other exceptions to be sent.
6565
66-
# sentry_event_filter.exs
66+
# sentry_event_filter.ex
6767
defmodule MyApp.SentryEventFilter do
6868
@behaviour Sentry.EventFilter
6969
70-
def exclude_exception?(:plug, %Elixir.Phoenix.Router.NoRouteError{}), do: true
71-
def exclude_exception?(_, ), do: false
70+
def exclude_exception?(%Elixir.Phoenix.Router.NoRouteError{}, :plug), do: true
71+
def exclude_exception?(_exception, _source), do: false
7272
end
7373
7474
# config.exs

lib/sentry/event_filter.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Sentry.EventFilter do
2-
@callback exclude_exception?(atom, Exception.t) :: any
2+
@callback exclude_exception?(Exception.t, atom) :: any
33
end
44

55
defmodule Sentry.DefaultEventFilter do

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%{"bunt": {:hex, :bunt, "0.1.6", "5d95a6882f73f3b9969fdfd1953798046664e6f77ec4e486e6fafc7caad97c6f", [:mix], []},
22
"bypass": {:hex, :bypass, "0.5.1", "cf3e8a4d376ee1dcd89bf362dfaf1f4bf4a6e19895f52fdc2bafbd8207ce435f", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]},
33
"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
4-
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
4+
"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:make, :rebar], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
55
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
66
"credo": {:hex, :credo, "0.5.3", "0c405b36e7651245a8ed63c09e2d52c2e2b89b6d02b1570c4d611e0fcbecf4a2", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]},
77
"earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []},

0 commit comments

Comments
 (0)