Exception: Syskit::AmbiguousServiceSelection

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

Overview

Exception raised when a service is being selected by type, but multiple services are available within the component that match the requested type

See Also:

  • UnknownServiceName

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_model, required_service, candidates) ⇒ AmbiguousServiceSelection

Returns a new instance of AmbiguousServiceSelection



213
214
215
216
# File 'lib/syskit/exceptions.rb', line 213

def initialize(task_model, required_service, candidates)
    @task_model, @required_service, @candidates =
        task_model, required_service, candidates
end

Instance Attribute Details

#candidatesArray<Models::BoundDataService> (readonly)

Returns the set of data services that matched the requested type

Returns:



211
212
213
# File 'lib/syskit/exceptions.rb', line 211

def candidates
  @candidates
end

#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



208
209
210
# File 'lib/syskit/exceptions.rb', line 208

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



206
207
208
# File 'lib/syskit/exceptions.rb', line 206

def task_model
  @task_model
end

Instance Method Details

#pretty_print(pp) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
# File 'lib/syskit/exceptions.rb', line 218

def pretty_print(pp)
    pp.text "there is an ambiguity while looking for a service of type #{required_service} in #{task_model.short_name}"
    pp.breakable
    pp.text "candidates are:"
    pp.nest(2) do
        pp.breakable
        pp.seplist(candidates) do |service|
            pp.text(service.name || service.to_s)
        end
    end
end