Class: Gruf::Errors::DebugInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/gruf/errors/debug_info.rb

Overview

Represents debugging information for an exception that occurred in a gRPC service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(detail, stack_trace = []) ⇒ DebugInfo

Returns a new instance of DebugInfo.

Parameters:

  • detail (String)

    The detail message of the exception

  • stack_trace (Array<String>) (defaults to: [])

    The stack trace generated by the exception as an array of strings



31
32
33
34
# File 'lib/gruf/errors/debug_info.rb', line 31

def initialize(detail, stack_trace = [])
  @detail = detail
  @stack_trace = stack_trace.is_a?(String) ? stack_trace.split("\n") : stack_trace
end

Instance Attribute Details

#detailString (readonly)

Returns The detail message of the exception.

Returns:

  • (String)

    The detail message of the exception



23
24
25
# File 'lib/gruf/errors/debug_info.rb', line 23

def detail
  @detail
end

#stack_traceArray<String> (readonly)

Returns The stack trace generated by the exception as an array of strings.

Returns:

  • (Array<String>)

    The stack trace generated by the exception as an array of strings



25
26
27
# File 'lib/gruf/errors/debug_info.rb', line 25

def stack_trace
  @stack_trace
end

Instance Method Details

#to_hHash

Return this object marshalled into a hash

Returns:

  • (Hash)

    The debug info represented as a has



41
42
43
44
45
46
# File 'lib/gruf/errors/debug_info.rb', line 41

def to_h
  {
    detail: detail,
    stack_trace: stack_trace
  }
end