Exception: Syskit::InvalidSelection

Inherits:
SpecError show all
Defined in:
lib/syskit/exceptions.rb

Overview

Raised when an incompatible dependency injection selection is given

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, selected, expected) ⇒ InvalidSelection

Returns a new instance of InvalidSelection



56
57
58
# File 'lib/syskit/exceptions.rb', line 56

def initialize(key, selected, expected)
    @key, @selected, @expected = key, selected, expected
end

Instance Attribute Details

#expectedObject (readonly)

The expected model



53
54
55
# File 'lib/syskit/exceptions.rb', line 53

def expected
  @expected
end

#keynil, Object (readonly)

The selection key

Returns:



49
50
51
# File 'lib/syskit/exceptions.rb', line 49

def key
  @key
end

#selectedObject (readonly)

The selection



51
52
53
# File 'lib/syskit/exceptions.rb', line 51

def selected
  @selected
end

Instance Method Details

#pretty_print(pp) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/syskit/exceptions.rb', line 60

def pretty_print(pp)
    if key
        pp.text "invalid selection for #{key}"
        pp.breakable
        pp.text "got "
    else
        pp.text "invalid selection: got "
    end
    selected.pretty_print(pp)
    pp.breakable
    pp.text "which provides"
    pp.nest(2) do
        selected.each_fullfilled_model do |m|
            pp.breakable
            m.pretty_print(pp)
        end
    end
    pp.breakable
    pp.text "expected something that provides "
    expected.pretty_print(pp)
end