Module: RedShift::AugmentedException

Included in:
LinkTypeError, RedShiftError, VarTypeError
Defined in:
lib/redshift/component.rb

Overview

Can be raised with a [msg, object] pair instead of just a msg string. In the former case, the object is accessible.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



14
15
16
# File 'lib/redshift/component.rb', line 14

def object
  @object
end

Instance Method Details

#initialize(*msg) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/redshift/component.rb', line 16

def initialize(*msg)
  if msg.empty?
    super; return
  end
  
  msg = msg.first if msg.size == 1
  if defined?(msg.first)
    msg, @object = *msg
    s = ((@object.inspect rescue
          @object.to_s) rescue
          "id ##{@object.object_id} of class #{@object.class}")
    msg += " Object is: $!.object == #{s}"
  end
  super msg
end