Class: Gruf::Errors::DebugInfo
- Inherits:
-
Object
- Object
- Gruf::Errors::DebugInfo
- 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
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#stack_trace ⇒ Object
readonly
Returns the value of attribute stack_trace.
Instance Method Summary collapse
-
#initialize(detail, stack_trace = []) ⇒ DebugInfo
constructor
A new instance of DebugInfo.
-
#to_h ⇒ Hash
Return this object marshalled into a hash.
Constructor Details
#initialize(detail, stack_trace = []) ⇒ DebugInfo
Returns a new instance of DebugInfo.
35 36 37 38 39 40 41 42 43 |
# File 'lib/gruf/errors/debug_info.rb', line 35 def initialize(detail, stack_trace = []) @detail = detail @stack_trace = (stack_trace.is_a?(String) ? stack_trace.split("\n") : stack_trace) # Limit the size of the stack trace to reduce risk of overflowing metadata stack_trace_limit = Gruf.backtrace_limit.to_i stack_trace_limit = 10 if stack_trace_limit.negative? @stack_trace = @stack_trace[0..stack_trace_limit] if stack_trace_limit.positive? end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
26 27 28 |
# File 'lib/gruf/errors/debug_info.rb', line 26 def detail @detail end |
#stack_trace ⇒ Object (readonly)
Returns the value of attribute stack_trace.
29 30 31 |
# File 'lib/gruf/errors/debug_info.rb', line 29 def stack_trace @stack_trace end |
Instance Method Details
#to_h ⇒ Hash
Return this object marshalled into a hash
50 51 52 53 54 55 |
# File 'lib/gruf/errors/debug_info.rb', line 50 def to_h { detail: detail, stack_trace: stack_trace } end |