Module: Raven::Utils::ExceptionCauseChain

Defined in:
lib/raven/utils/exception_cause_chain.rb

Class Method Summary collapse

Class Method Details

.exception_to_array(exception) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/raven/utils/exception_cause_chain.rb', line 4

def self.exception_to_array(exception)
  if exception.respond_to?(:cause) && exception.cause
    exceptions = [exception]
    while exception.cause
      exception = exception.cause
      break if exceptions.any? { |e| e.object_id == exception.object_id }
      exceptions << exception
    end
    exceptions
  else
    [exception]
  end
end