Exception: Syskit::NoMatchingService
- 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
Direct Known Subclasses
Instance Attribute Summary collapse
-
#required_service ⇒ Model<DataService>
readonly
The model of data service we were looking for.
-
#task_model ⇒ Model<Component>
readonly
The component on which we were looking for a given service.
Instance Method Summary collapse
-
#initialize(task_model, required_service) ⇒ NoMatchingService
constructor
A new instance of NoMatchingService.
- #pretty_print(pp) ⇒ Object
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_service ⇒ Model<DataService> (readonly)
Returns 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_model ⇒ Model<Component> (readonly)
Returns 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 |