Class: AppMap::Event::MethodReturn

Inherits:
MethodReturnIgnoreValue show all
Defined in:
lib/appmap/event.rb

Constant Summary

Constants inherited from MethodEvent

AppMap::Event::MethodEvent::LIMIT

Instance Attribute Summary collapse

Attributes inherited from MethodReturnIgnoreValue

#elapsed, #parent_id

Attributes inherited from MethodEventStruct

#event, #id, #thread_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MethodEvent

display_string

Instance Attribute Details

#exceptionsObject

Returns the value of attribute exceptions.



168
169
170
# File 'lib/appmap/event.rb', line 168

def exceptions
  @exceptions
end

#return_valueObject

Returns the value of attribute return_value.



168
169
170
# File 'lib/appmap/event.rb', line 168

def return_value
  @return_value
end

Class Method Details

.build_from_invocation(mr = MethodReturn.new, parent_id, elapsed, return_value, exception) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/appmap/event.rb', line 171

def build_from_invocation(mr = MethodReturn.new, parent_id, elapsed, return_value, exception)
  mr.tap do |_|
    if return_value
      mr.return_value = {
        class: return_value.class.name,
        value: display_string(return_value),
        object_id: return_value.__id__
      }
    end
    if exception
      next_exception = exception
      exceptions = []
      while next_exception
        exception_backtrace = next_exception.backtrace_locations.try(:[], 0)
        exceptions << {
          class: next_exception.class.name,
          message: next_exception.message,
          object_id: next_exception.__id__,
          path: exception_backtrace&.path,
          lineno: exception_backtrace&.lineno
        }.compact
        next_exception = next_exception.cause
      end

      mr.exceptions = exceptions
    end
    MethodReturnIgnoreValue.build_from_invocation(mr, parent_id, elapsed)
  end
end

Instance Method Details

#to_hObject



202
203
204
205
206
207
# File 'lib/appmap/event.rb', line 202

def to_h
  super.tap do |h|
    h[:return_value] = return_value if return_value
    h[:exceptions] = exceptions if exceptions
  end
end