Class: Sentry::ExceptionInterface

Inherits:
Interface show all
Defined in:
lib/sentry/interfaces/exception.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Interface

inherited, registered

Constructor Details

#initialize(values:) ⇒ ExceptionInterface

Returns a new instance of ExceptionInterface.



3
4
5
# File 'lib/sentry/interfaces/exception.rb', line 3

def initialize(values:)
  @values = values
end

Class Method Details

.build(exception:, stacktrace_builder:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sentry/interfaces/exception.rb', line 13

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

Instance Method Details

#to_hashObject



7
8
9
10
11
# File 'lib/sentry/interfaces/exception.rb', line 7

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