Sha256: 3312844062f2c6d7ab58bdd1d78e6b3e631ca6880810ea46c74babec11322164

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true

module Sentry
  class ExceptionInterface < Interface
    def initialize(values:)
      @values = values
    end

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

    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(values: exceptions)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sentry-ruby-core-4.8.3 lib/sentry/interfaces/exception.rb
sentry-ruby-core-4.8.2 lib/sentry/interfaces/exception.rb
sentry-ruby-core-4.8.1 lib/sentry/interfaces/exception.rb