Module: ActiveSupport::Notifications::FanoutIteration

Included in:
Fanout, ActiveSupport::Notifications::Fanout::BaseGroup
Defined in:
activesupport/lib/active_support/notifications/fanout.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#iterate_guarding_exceptions(listeners) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 21

def iterate_guarding_exceptions(listeners)
  exceptions = nil

  listeners.each do |s|
    yield s
  rescue Exception => e
    exceptions ||= []
    exceptions << e
  end

  if exceptions
    if exceptions.size == 1
      raise exceptions.first
    else
      raise InstrumentationSubscriberError.new(exceptions), cause: exceptions.first
    end
  end

  listeners
end