Exception: RfcReader::ErrorContext::ContextError

Inherits:
StandardError
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rfc_reader/error_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cause:, context: nil) ⇒ ContextError

Returns a new instance of ContextError.

Parameters:

  • cause (StandardError)
  • context (String) (defaults to: nil)

    (Optional)



16
17
18
19
20
# File 'lib/rfc_reader/error_context.rb', line 16

def initialize(cause:, context: nil)
  @cause = cause
  @context = context || default_context
  super
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



10
11
12
# File 'lib/rfc_reader/error_context.rb', line 10

def context
  @context
end

Instance Method Details

#full_messageObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rfc_reader/error_context.rb', line 26

def full_message
  <<~MESSAGE
    Context:
    #{indent(@context)}
    Error:
       #{@cause.class}
    Message:
    #{indent(message)}
    Backtrace:
    #{indent(backtrace)}
  MESSAGE
end

#short_messageObject



22
23
24
# File 'lib/rfc_reader/error_context.rb', line 22

def short_message
  "Error: #{context}"
end