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]"
- OMISSION_MARK =
"..."
- MAX_LOCAL_BYTES =
1024
Instance Attribute Summary collapse
-
#mechanism ⇒ Object
readonly
Returns the value of attribute mechanism.
-
#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
Returns the value of attribute value.
Class Method Summary collapse
-
.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:) ⇒ Object
patch this method if you want to change an exception’s stacktrace frames also see ‘StacktraceBuilder.build`.
Instance Method Summary collapse
-
#initialize(exception:, mechanism:, stacktrace: nil) ⇒ SingleExceptionInterface
constructor
A new instance of SingleExceptionInterface.
- #to_hash ⇒ Object
Constructor Details
#initialize(exception:, mechanism:, stacktrace: nil) ⇒ SingleExceptionInterface
Returns a new instance of SingleExceptionInterface.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sentry/interfaces/single_exception.rb', line 17 def initialize(exception:, mechanism:, stacktrace: nil) @type = exception.class.to_s = if exception.respond_to?(:detailed_message) exception.(highlight: false) else exception. || "" end = .inspect unless .is_a?(String) @value = Utils::EncodingHelper.encode_to_utf_8(.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 @mechanism = mechanism end |
Instance Attribute Details
#mechanism ⇒ Object (readonly)
Returns the value of attribute mechanism.
14 15 16 |
# File 'lib/sentry/interfaces/single_exception.rb', line 14 def mechanism @mechanism end |
#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
Returns the value of attribute value.
15 16 17 |
# File 'lib/sentry/interfaces/single_exception.rb', line 15 def value @value end |
Class Method Details
.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:) ⇒ Object
patch this method if you want to change an exception’s stacktrace frames also see ‘StacktraceBuilder.build`.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sentry/interfaces/single_exception.rb', line 44 def self.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:) 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 Utils::EncodingHelper.encode_to_utf_8(v) rescue StandardError PROBLEMATIC_LOCAL_VALUE_REPLACEMENT end end stacktrace.frames.last.vars = locals end new(exception: exception, stacktrace: stacktrace, mechanism: mechanism) end |
Instance Method Details
#to_hash ⇒ Object
35 36 37 38 39 40 |
# File 'lib/sentry/interfaces/single_exception.rb', line 35 def to_hash data = super data[:stacktrace] = data[:stacktrace].to_hash if data[:stacktrace] data[:mechanism] = data[:mechanism].to_hash data end |