Exception: Syskit::NoMatchingService

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

Overview

Exception raised when a service of a given type is required but none can be found on a particular task context model

See Also:

  • AmbiguousServiceSelection

Direct Known Subclasses

NoMatchingServiceForCompositionChild

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_model, required_service) ⇒ NoMatchingService

Returns a new instance of NoMatchingService



131
132
133
134
# File 'lib/syskit/exceptions.rb', line 131

def initialize(task_model, required_service)
    @task_model, @required_service =
        [*task_model], required_service
end

Instance Attribute Details

#required_serviceModel<DataService> (readonly)

Returns the model of data service we were looking for

Returns:

  • (Model<DataService>)

    the model of data service we were looking for



129
130
131
# File 'lib/syskit/exceptions.rb', line 129

def required_service
  @required_service
end

#task_modelModel<Component> (readonly)

Returns the component on which we were looking for a given service

Returns:

  • (Model<Component>)

    the component on which we were looking for a given service



127
128
129
# File 'lib/syskit/exceptions.rb', line 127

def task_model
  @task_model
end

Instance Method Details

#pretty_print(pp) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/syskit/exceptions.rb', line 136

def pretty_print(pp)
    name = task_model.map(&:short_name).join(", ")
    candidates = task_model.inject([]) { |set, m| set.concat(m.each_data_service.to_a) }
    pp.text "there are no services in #{name} that provide the service #{required_service}"
    pp.breakable
    pp.text "the services of #{name} are:"
    pp.nest(2) do
        pp.breakable
        pp.seplist(candidates) do |srv|
            _, srv = *srv
            pp.text "#{srv.full_name}: #{srv.model.short_name}"
        end
    end
end