Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for boolean option in :ignore config #53

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end

### Ignore

You can ignore certain types of errors by specifying `:ignore` config key:
You can ignore all errors or certain types of errors by specifying `:ignore` config key:

```elixir
config :airbrakex,
Expand All @@ -102,6 +102,10 @@ config :airbrakex,
true -> false
end
end
# OR
# Boolean
# Ignore all errors (from :test environment, for example)
ignore: true
```


Expand Down
6 changes: 5 additions & 1 deletion lib/airbrakex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Airbrakex do
end
```

You can ignore certain types of errors by specifying `:ignore` config key:
You can ignore all errors or certain types of errors by specifying `:ignore` config key:

```elixir
config :airbrakex,
Expand All @@ -45,6 +45,10 @@ defmodule Airbrakex do
true -> false
end
end
# OR
# Boolean
# Ignore all errors (from :test environment, for example)
ignore: true
```
"""

Expand Down
1 change: 1 addition & 0 deletions lib/airbrakex/notifier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ defmodule Airbrakex.Notifier do
defp proceed?(ignore, _error) when is_nil(ignore), do: true
defp proceed?({module, function, []}, error), do: !apply(module, function, [error])
defp proceed?(ignore, error) when is_function(ignore), do: !ignore.(error)
defp proceed?(ignore, _error) when is_boolean(ignore), do: !ignore

defp proceed?(ignore, error) when is_list(ignore) do
type = error_type(error)
Expand Down
8 changes: 8 additions & 0 deletions test/airbrakex/notifier_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ defmodule Airbrakex.NotifierTest do
Airbrakex.Notifier.notify(error)
end

test "accepts boolean as ignore value", %{bypass: bypass, error: error} do
Application.put_env(:airbrakex, :ignore, true)

Bypass.pass(bypass)

Airbrakex.Notifier.notify(error)
end

test "does not notify if error in ignore list", %{bypass: bypass} do
Application.put_env(:airbrakex, :ignore, [SpecificError])

Expand Down