Class: Sentry::SingleExceptionInterface
- Includes:
- CustomInspection
- Defined in:
- lib/sentry/interfaces/single_exception.rb
Constant Summary collapse
- SKIP_INSPECTION_ATTRIBUTES =
[:@stacktrace]
- PROBLEMATIC_LOCAL_VALUE_REPLACEMENT =
"[ignored due to error]".freeze
- OMISSION_MARK =
"...".freeze
- MAX_LOCAL_BYTES =
1024
Instance Attribute Summary collapse
-
#module ⇒ Object
readonly
Returns the value of attribute module.
-
#stacktrace ⇒ Object
readonly
Returns the value of attribute stacktrace.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.build_with_stacktrace(exception:, stacktrace_builder:) ⇒ Object
patch this method if you want to change an exception’s stacktrace frames also see
StacktraceBuilder.build.
Instance Method Summary collapse
-
#initialize(exception:, stacktrace: nil) ⇒ SingleExceptionInterface
constructor
A new instance of SingleExceptionInterface.
- #to_hash ⇒ Object
Constructor Details
#initialize(exception:, stacktrace: nil) ⇒ SingleExceptionInterface
Returns a new instance of SingleExceptionInterface.
16 17 18 19 20 21 22 |
# File 'lib/sentry/interfaces/single_exception.rb', line 16 def initialize(exception:, stacktrace: nil) @type = exception.class.to_s @value = (exception. || "").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
#module ⇒ Object (readonly)
Returns the value of attribute module.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 def module @module end |
#stacktrace ⇒ Object (readonly)
Returns the value of attribute stacktrace.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 def stacktrace @stacktrace end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 def thread_id @thread_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sentry/interfaces/single_exception.rb', line 32 def self.build_with_stacktrace(exception:, stacktrace_builder:) stacktrace = stacktrace_builder.build(backtrace: exception.backtrace) if locals = exception.instance_variable_get(:@sentry_locals) locals.each do |k, v| locals[k] = begin v = v.inspect unless v.is_a?(String) if v.length >= MAX_LOCAL_BYTES v = v.byteslice(0..MAX_LOCAL_BYTES - 1) + OMISSION_MARK end v rescue StandardError PROBLEMATIC_LOCAL_VALUE_REPLACEMENT end end stacktrace.frames.last.vars = locals end new(exception: exception, stacktrace: stacktrace) end |
Instance Method Details
#to_hash ⇒ Object
24 25 26 27 28 |
# File 'lib/sentry/interfaces/single_exception.rb', line 24 def to_hash data = super data[:stacktrace] = data[:stacktrace].to_hash if data[:stacktrace] data end |