Exception: Hodor::NestedError
- Inherits:
-
StandardError
- Object
- StandardError
- Hodor::NestedError
- Defined in:
- lib/hodor.rb
Overview
Hodor Exception Classes
Direct Known Subclasses
Hdfs::FailedToGetFile, Hdfs::FailedToPutDir, Hdfs::FailedToPutFile, Hdfs::FailedToRemovePath
Instance Attribute Summary collapse
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
Instance Method Summary collapse
-
#initialize(cause, kvp = {}) ⇒ NestedError
constructor
A new instance of NestedError.
- #orig_to_s ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cause, kvp = {}) ⇒ NestedError
Returns a new instance of NestedError.
9 10 11 12 |
# File 'lib/hodor.rb', line 9 def initialize(cause, kvp = {}) @cause = cause @kvp = kvp end |
Instance Attribute Details
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
7 8 9 |
# File 'lib/hodor.rb', line 7 def cause @cause end |
Instance Method Details
#orig_to_s ⇒ Object
14 |
# File 'lib/hodor.rb', line 14 alias :orig_to_s :to_s |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hodor.rb', line 15 def to_s msg = @kvp[:msg] || orig_to_s if @kvp.size > 1 || (@kvp.size == 1 && !@kvp.has_key?(:msg)) msg << " Exception Context:\n" @kvp.each_pair { |k,v| next if k == :msg if k.nil? msg << " nil => " elsif k.is_a?(Symbol) msg << " :#{k.to_s} => " else msg << " #{k} => " end if v.nil? msg << "nil" elsif v.is_a?(Symbol) msg << ":#{v.to_s}" else msg << v end msg << "\n" } end msg << "Root cause: #{@cause}" msg << "\nBacktrace:\n " msg << "#{@cause.backtrace[0..5].join("\n ")}" end |