method
iterate_guarding_exceptions
v8.1.1 -
Show latest stable
- Class:
ActiveSupport::Notifications::FanoutIteration
iterate_guarding_exceptions(collection, &block)private
No documentation available.
# File activesupport/lib/active_support/notifications/fanout.rb, line 20
def iterate_guarding_exceptions(collection, &block)
case collection.size
when 0
when 1
collection.each(&block)
else
exceptions = nil
collection.each do |s|
yield s
rescue Exception => e
exceptions ||= []
exceptions << e
end
if exceptions
exceptions = exceptions.flat_map do |exception|
exception.is_a?(InstrumentationSubscriberError) ? exception.exceptions : [exception]
end
if exceptions.size == 1
raise exceptions.first
else
raise InstrumentationSubscriberError.new(exceptions), cause: exceptions.first
end
end
end
collection
end