getsentry/raven-ruby

View on GitHub
sentry-ruby/lib/sentry/utils/exception_cause_chain.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Sentry
  module Utils
    module ExceptionCauseChain
      def self.exception_to_array(exception)
        exceptions = [exception]

        while exception.cause
          exception = exception.cause
          break if exceptions.any? { |e| e.object_id == exception.object_id }

          exceptions << exception
        end

        exceptions
      end
    end
  end
end