mirror of
https://github.com/meineerde/rackstash.git
synced 2026-01-31 17:27:13 +00:00
Allow to set the Flow#raise_on_error setting with the same getter/setter protocol as all the other values
This commit is contained in:
parent
96f102875f
commit
bdeb0534c9
@ -220,6 +220,18 @@ module Rackstash
|
||||
end
|
||||
alias filter_prepend filter_unshift
|
||||
|
||||
# Get or set the raise_on_error setting. Only if set to `true`, we will
|
||||
# re-raise errors occuring during logging. If set to `false` (the default),
|
||||
# we will only log the exception to the {#error_flow} and swallow it.
|
||||
#
|
||||
# @param bool [Bool] the value to set. If omitted, we just return the
|
||||
# current setting
|
||||
# @return [Bool] the updated or current `raise_on_error` setting
|
||||
def raise_on_error(bool = UNDEFINED)
|
||||
self.raise_on_error = bool unless UNDEFINED.equal? bool
|
||||
raise_on_error?
|
||||
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
|
||||
|
||||
@ -298,19 +298,24 @@ describe Rackstash::Flow do
|
||||
describe '#raise_on_error?' do
|
||||
it 'defaults to false' do
|
||||
expect(flow.raise_on_error?).to eql false
|
||||
expect(flow.raise_on_error).to eql false
|
||||
end
|
||||
|
||||
it 'can set a boolean' do
|
||||
flow.raise_on_error = 'something'
|
||||
it 'can set to true or false' do
|
||||
expect(flow.raise_on_error 'something').to eql true
|
||||
expect(flow.raise_on_error).to eql true
|
||||
expect(flow.raise_on_error?).to eql true
|
||||
|
||||
flow.raise_on_error = nil
|
||||
expect(flow.raise_on_error nil).to eql false
|
||||
expect(flow.raise_on_error).to eql false
|
||||
expect(flow.raise_on_error?).to eql false
|
||||
|
||||
flow.raise_on_error = true
|
||||
expect(flow.raise_on_error true).to eql true
|
||||
expect(flow.raise_on_error).to eql true
|
||||
expect(flow.raise_on_error?).to eql true
|
||||
|
||||
flow.raise_on_error = false
|
||||
expect(flow.raise_on_error false).to eql false
|
||||
expect(flow.raise_on_error).to eql false
|
||||
expect(flow.raise_on_error?).to eql false
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user