Skip to content

Commit

Permalink
Allow classes to be passed into data_sync_excluded_exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBAshton committed Oct 21, 2020
1 parent 406947f commit 4130f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/govuk_app_config/govuk_error/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def should_capture=(closure)
def ignore_excluded_exceptions_in_data_sync
lambda { |error_or_event|
data_sync_ignored_error = data_sync_excluded_exceptions.any? do |exception_to_ignore|
exception_to_ignore = Object.const_get(exception_to_ignore)
exception_to_ignore = Object.const_get(exception_to_ignore) unless exception_to_ignore.is_a?(Module)
exception_chain = Raven::Utils::ExceptionCauseChain.exception_to_array(error_or_event)
exception_chain.any? { |exception| exception.is_a?(exception_to_ignore) }
rescue NameError
Expand Down
8 changes: 7 additions & 1 deletion spec/govuk_error/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
expect(configuration.should_capture.call(StandardError.new)).to eq(true)
end

it "should ignore errors that have been added to data_sync_excluded_exceptions" do
it "should ignore errors that have been added as a string to data_sync_excluded_exceptions" do
configuration.data_sync_excluded_exceptions << "StandardError"

expect(configuration.should_capture.call(StandardError.new)).to eq(false)
end

it "should ignore errors that have been added as a class to data_sync_excluded_exceptions" do
configuration.data_sync_excluded_exceptions << StandardError

expect(configuration.should_capture.call(StandardError.new)).to eq(false)
end

it "should ignore errors whose underlying cause is an exception in data_sync_excluded_exceptions" do
stub_const("ErrorWeCareAbout", Class.new(StandardError))
stub_const("SomeOtherError", Class.new(StandardError))
Expand Down

0 comments on commit 4130f3d

Please sign in to comment.