Module: DelayedExceptions

Included in:
Krane::TemplateSets
Defined in:
lib/krane/delayed_exceptions.rb

Instance Method Summary collapse

Instance Method Details

#with_delayed_exceptions(enumerable, *catch, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/krane/delayed_exceptions.rb', line 4

def with_delayed_exceptions(enumerable, *catch, &block)
  exceptions = []
  enumerable.each do |i|
    begin
      block.call(i)
    rescue *catch => e
      exceptions << e
    end
  end.tap { raise exceptions.first if exceptions.first }
end