Exception: Uinit::Type::Error
- Inherits:
-
TypeError
- Object
- TypeError
- Uinit::Type::Error
- Defined in:
- lib/uinit/type/error.rb
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#traces ⇒ Object
readonly
Returns the value of attribute traces.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(error_message, types, depth, trace = []) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
- #trace(type, trace) ⇒ Object
Constructor Details
#initialize(error_message, types, depth, trace = []) ⇒ Error
Returns a new instance of Error.
6 7 8 9 10 11 12 13 |
# File 'lib/uinit/type/error.rb', line 6 def initialize(, types, depth, trace = []) super() @error_message = @types = types @depth = depth @traces = trace end |
Instance Attribute Details
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
15 16 17 |
# File 'lib/uinit/type/error.rb', line 15 def depth @depth end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
15 16 17 |
# File 'lib/uinit/type/error.rb', line 15 def @error_message end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
15 16 17 |
# File 'lib/uinit/type/error.rb', line 15 def instance @instance end |
#traces ⇒ Object (readonly)
Returns the value of attribute traces.
15 16 17 |
# File 'lib/uinit/type/error.rb', line 15 def traces @traces end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
15 16 17 |
# File 'lib/uinit/type/error.rb', line 15 def types @types end |
#value ⇒ Object
Returns the value of attribute value.
16 17 18 |
# File 'lib/uinit/type/error.rb', line 16 def value @value end |
Instance Method Details
#message ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/uinit/type/error.rb', line 23 def msg = msg = if types.size == 1 "#{msg}\nType: #{types.first}" else "#{msg}\nTypes:\n #{types * "\n "}" end msg = "#{msg}\nTraces: #{traces.join}" unless traces.empty? msg = "#{msg}\nValue: #{value.inspect}" if value msg end |
#trace(type, trace) ⇒ Object
18 19 20 21 |
# File 'lib/uinit/type/error.rb', line 18 def trace(type, trace) types.unshift(type) traces.unshift(trace) end |