Sha256: 7ac8b3bc8cec0100ce94811a16608197df54e83d63cad5da502ee9b9ac358e5c

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Sentry
  class ExceptionInterface < Interface
    # @param exceptions [Array<SingleExceptionInterface>]
    def initialize(exceptions:)
      @values = exceptions
    end

    # @return [Hash]
    def to_hash
      data = super
      data[:values] = data[:values].map(&:to_hash) if data[:values]
      data
    end

    # Builds ExceptionInterface with given exception and stacktrace_builder.
    # @param exception [Exception]
    # @param stacktrace_builder [StacktraceBuilder]
    # @see SingleExceptionInterface#build_with_stacktrace
    # @see SingleExceptionInterface#initialize
    # @return [ExceptionInterface]
    def self.build(exception:, stacktrace_builder:)
      exceptions = Sentry::Utils::ExceptionCauseChain.exception_to_array(exception).reverse
      processed_backtrace_ids = Set.new

      exceptions = exceptions.map do |e|
        if e.backtrace && !processed_backtrace_ids.include?(e.backtrace.object_id)
          processed_backtrace_ids << e.backtrace.object_id
          SingleExceptionInterface.build_with_stacktrace(exception: e, stacktrace_builder: stacktrace_builder)
        else
          SingleExceptionInterface.new(exception: exception)
        end
      end

      new(exceptions: exceptions)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sentry-ruby-core-5.1.1 lib/sentry/interfaces/exception.rb
sentry-ruby-core-5.1.0 lib/sentry/interfaces/exception.rb
sentry-ruby-core-5.0.2 lib/sentry/interfaces/exception.rb
sentry-ruby-core-5.0.1 lib/sentry/interfaces/exception.rb
sentry-ruby-core-5.0.0 lib/sentry/interfaces/exception.rb
sentry-ruby-core-4.9.2 lib/sentry/interfaces/exception.rb
sentry-ruby-core-4.9.1 lib/sentry/interfaces/exception.rb
sentry-ruby-core-4.9.0 lib/sentry/interfaces/exception.rb