Module: Webhookdb::Errors
- Defined in:
- lib/webhookdb/errors.rb
Class Method Summary collapse
-
.each_cause(ex) ⇒ Object
Call the given block for the given exception, each cause (see Exception#cause), and each wrapped errors (see Amigo::Retry::Error#wrapped).
-
.find_cause(ex) ⇒ Object
Run the given block for each cause (see +each_cause), returning the first exception the block returns
true
for.
Class Method Details
.each_cause(ex) ⇒ Object
Call the given block for the given exception, each cause (see Exception#cause), and each wrapped errors (see Amigo::Retry::Error#wrapped). If the block returns true
for any exception, stop walking.
8 9 10 11 12 13 14 15 16 |
# File 'lib/webhookdb/errors.rb', line 8 def each_cause(ex, &) raise LocalJumpError unless block_given? return true if yield(ex) == true caused_got = ex.cause && each_cause(ex.cause, &) return true if caused_got == true wrapped_got = ex.respond_to?(:wrapped) && ex.wrapped && each_cause(ex.wrapped, &) return true if wrapped_got == true return nil end |
.find_cause(ex) ⇒ Object
Run the given block for each cause (see +each_cause), returning the first exception the block returns true
for.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/webhookdb/errors.rb', line 20 def find_cause(ex, &) raise LocalJumpError unless block_given? got = nil each_cause(ex) do |cause| if yield(cause) == true got = cause true else false end end return got end |