Class: Sentry::SingleExceptionInterface

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Interface

inherited, registered

Constructor Details

#initialize(exception:, stacktrace: nil) ⇒ SingleExceptionInterface



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

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

Instance Attribute Details

#moduleObject (readonly)

Returns the value of attribute module.



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

def module
  @module
end

#stacktraceObject (readonly)

Returns the value of attribute stacktrace.



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

def stacktrace
  @stacktrace
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



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

def thread_id
  @thread_id
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.build_with_stacktrace(exception:, stacktrace_builder:) ⇒ Object

patch this method if you want to change an exception’s stacktrace frames also see StacktraceBuilder.build.



21
22
23
24
# File 'lib/sentry/interfaces/single_exception.rb', line 21

def self.build_with_stacktrace(exception:, stacktrace_builder:)
  stacktrace = stacktrace_builder.build(backtrace: exception.backtrace)
  new(exception: exception, stacktrace: stacktrace)
end

Instance Method Details

#to_hashObject



13
14
15
16
17
# File 'lib/sentry/interfaces/single_exception.rb', line 13

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