diff --git a/lib/rackstash/flow.rb b/lib/rackstash/flow.rb index 56a4a8c..e0a4322 100644 --- a/lib/rackstash/flow.rb +++ b/lib/rackstash/flow.rb @@ -279,6 +279,14 @@ module Rackstash raise_on_error? end + # Set the {#raise_on_error} flag to true in order to re-raise any exceptions + # which occured during logging. + # + # @see raise_on_error + def raise_on_error! + self.raise_on_error = true + end + # @return [Bool] `true` if we re-raise any occured errors after logging them # to the {#error_flow}. This can aid in debugging. By default, i.e., with # {#raise_on_error?} being `false`, we swallow errors after logging them diff --git a/spec/rackstash/flow_spec.rb b/spec/rackstash/flow_spec.rb index 8235d1d..58a102a 100644 --- a/spec/rackstash/flow_spec.rb +++ b/spec/rackstash/flow_spec.rb @@ -374,6 +374,14 @@ RSpec.describe Rackstash::Flow do end end + describe '#raise_on_error!' do + it 'sets the flag to true' do + expect { flow.raise_on_error! }.to change { flow.raise_on_error? } + .from(false) + .to(true) + end + end + describe '#reopen' do it 'calls adapter#reopen' do expect(adapter).to receive(:reopen).and_return(true)