From b43a2887319ca2ee9a9132f8f8ced409c7b547da Mon Sep 17 00:00:00 2001 From: ktravers Date: Wed, 23 Jan 2019 19:57:46 -0500 Subject: [PATCH 1/2] add method, test --- lib/airbrakex/notifier.ex | 1 + test/airbrakex/notifier_test.exs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/airbrakex/notifier.ex b/lib/airbrakex/notifier.ex index 0e46f24..83ba163 100644 --- a/lib/airbrakex/notifier.ex +++ b/lib/airbrakex/notifier.ex @@ -76,6 +76,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: !Enum.any?(ignore, fn el -> el == error.type end) diff --git a/test/airbrakex/notifier_test.exs b/test/airbrakex/notifier_test.exs index e2ac4b6..14a119e 100644 --- a/test/airbrakex/notifier_test.exs +++ b/test/airbrakex/notifier_test.exs @@ -117,6 +117,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 "accepts MFA tuple as ignore value", %{bypass: bypass, error: error} do defmodule IgnoreTest do def ignore(_error) do @@ -130,7 +138,7 @@ defmodule Airbrakex.NotifierTest do Airbrakex.Notifier.notify(error) end - + test "passes http_options to the HTTPoison request", %{bypass: bypass, error: error} do Application.put_env(:airbrakex, :http_options, params: [custom_param: "custom_value"]) From d4f99a2f6b17b430f41a3991138ab4a83eacee15 Mon Sep 17 00:00:00 2001 From: ktravers Date: Wed, 23 Jan 2019 19:57:54 -0500 Subject: [PATCH 2/2] update docs --- README.md | 6 +++++- lib/airbrakex.ex | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54496d2..51015d7 100644 --- a/README.md +++ b/README.md @@ -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, @@ -102,6 +102,10 @@ config :airbrakex, true -> false end end + # OR + # Boolean + # Ignore all errors (from :test environment, for example) + ignore: true ``` diff --git a/lib/airbrakex.ex b/lib/airbrakex.ex index eab9689..dd51aef 100644 --- a/lib/airbrakex.ex +++ b/lib/airbrakex.ex @@ -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, @@ -45,6 +45,10 @@ defmodule Airbrakex do true -> false end end + # OR + # Boolean + # Ignore all errors (from :test environment, for example) + ignore: true ``` """