Sha256: 3f2efae5ee93e6c3e2ff7eeb913cac3ae9eac96d420030e740c0dd0b25831759

Contents?: true

Size: 914 Bytes

Versions: 22

Compression:

Stored size: 914 Bytes

Contents

module Sentry
  class SingleExceptionInterface < Interface
    attr_reader :type, :value, :module, :thread_id, :stacktrace

    def initialize(exception:, stacktrace: nil)
      @type = exception.class.to_s
      @value = (exception.message || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
      @module = exception.class.to_s.split('::')[0...-1].join('::')
      @thread_id = Thread.current.object_id
      @stacktrace = stacktrace
    end

    def to_hash
      data = super
      data[:stacktrace] = data[:stacktrace].to_hash if data[:stacktrace]
      data
    end

    # patch this method if you want to change an exception's stacktrace frames
    # also see `StacktraceBuilder.build`.
    def self.build_with_stacktrace(exception:, stacktrace_builder:)
      stacktrace = stacktrace_builder.build(backtrace: exception.backtrace)
      new(exception: exception, stacktrace: stacktrace)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sentry-ruby-core-4.3.1 lib/sentry/interfaces/single_exception.rb
sentry-ruby-core-4.3.0 lib/sentry/interfaces/single_exception.rb