Exception: Pocolog::Upgrade::NoChain

Inherits:
InvalidCast
  • Object
show all
Defined in:
lib/pocolog/upgrade/exceptions.rb

Overview

Exception raised when a conversion chain cannot be found

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_type, to_type, failures) ⇒ NoChain

Returns a new instance of NoChain



16
17
18
19
20
# File 'lib/pocolog/upgrade/exceptions.rb', line 16

def initialize(from_type, to_type, failures)
    @from_type = from_type
    @to_type   = to_type
    @failures  = failures
end

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures



14
15
16
# File 'lib/pocolog/upgrade/exceptions.rb', line 14

def failures
  @failures
end

#from_typeObject (readonly)

Returns the value of attribute from_type



12
13
14
# File 'lib/pocolog/upgrade/exceptions.rb', line 12

def from_type
  @from_type
end

#to_typeObject (readonly)

Returns the value of attribute to_type



13
14
15
# File 'lib/pocolog/upgrade/exceptions.rb', line 13

def to_type
  @to_type
end

Instance Method Details

#pretty_print(pp) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pocolog/upgrade/exceptions.rb', line 22

def pretty_print(pp)
    if from_type.name == to_type.name
        pp.text "no upgrade chain for #{from_type.name}"
    else
        pp.text "no conversion chain from #{from_type.name} to #{to_type.name}"
    end

    failures.each do |e|
        pp.nest(2) do
            pp.breakable
            e.pretty_print(pp)
        end
    end
end