Class: Lapsoss::ExceptionBacktraceFrame

Inherits:
Object
  • Object
show all
Defined in:
lib/lapsoss/exception_backtrace_frame.rb

Overview

Wrapper for BacktraceFrame that adds exception-specific metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frame, exception_class: nil, is_crash_frame: false) ⇒ ExceptionBacktraceFrame

Returns a new instance of ExceptionBacktraceFrame.



8
9
10
11
12
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 8

def initialize(frame, exception_class: nil, is_crash_frame: false)
  @frame = frame
  @exception_class = exception_class
  @is_crash_frame = is_crash_frame
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object

Delegate all other methods to the wrapped frame



19
20
21
22
23
24
25
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 19

def method_missing(method, *, &)
  if @frame.respond_to?(method)
    @frame.send(method, *, &)
  else
    super
  end
end

Instance Attribute Details

#exception_classObject (readonly)

Returns the value of attribute exception_class.



6
7
8
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 6

def exception_class
  @exception_class
end

#frameObject (readonly)

Returns the value of attribute frame.



6
7
8
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 6

def frame
  @frame
end

#is_crash_frameObject (readonly)

Returns the value of attribute is_crash_frame.



6
7
8
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 6

def is_crash_frame
  @is_crash_frame
end

Instance Method Details

#crash_frame?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 14

def crash_frame?
  @is_crash_frame
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 27

def respond_to_missing?(method, include_private = false)
  @frame.respond_to?(method, include_private) || super
end

#to_hObject

Override to_h to include exception metadata



32
33
34
35
36
37
# File 'lib/lapsoss/exception_backtrace_frame.rb', line 32

def to_h
  @frame.to_h.merge(
    exception_class: @exception_class,
    crash_frame: @is_crash_frame
  ).compact
end