Exception: Pangea::Errors::PangeaError
- Defined in:
- lib/pangea/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cause_chain ⇒ Object
readonly
Returns the value of attribute cause_chain.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #detailed_message ⇒ Object
-
#initialize(message, context: {}, cause: nil) ⇒ PangeaError
constructor
A new instance of PangeaError.
- #to_h ⇒ Object
Constructor Details
#initialize(message, context: {}, cause: nil) ⇒ PangeaError
Returns a new instance of PangeaError.
22 23 24 25 26 27 |
# File 'lib/pangea/errors.rb', line 22 def initialize(, context: {}, cause: nil) super() @context = context @cause_chain = build_cause_chain(cause || self.cause) @timestamp = Time.now end |
Instance Attribute Details
#cause_chain ⇒ Object (readonly)
Returns the value of attribute cause_chain.
20 21 22 |
# File 'lib/pangea/errors.rb', line 20 def cause_chain @cause_chain end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
20 21 22 |
# File 'lib/pangea/errors.rb', line 20 def context @context end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
20 21 22 |
# File 'lib/pangea/errors.rb', line 20 def @timestamp end |
Instance Method Details
#detailed_message ⇒ Object
29 30 31 32 33 34 |
# File 'lib/pangea/errors.rb', line 29 def lines = ["[#{@timestamp.iso8601}] #{self.class.name}: #{}"] lines << "Context: #{format_context}" if @context.any? lines << "Cause chain:\n#{format_cause_chain}" if @cause_chain.any? lines.join("\n") end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/pangea/errors.rb', line 36 def to_h { error_type: self.class.name, message: , context: @context, cause_chain: @cause_chain, timestamp: @timestamp.iso8601 } end |