-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: improve error message in case of wrong return types
at the moment the follwoing code produces an error which is not really addressing the issue Robot.actions do describe('move robot') def move(arg) Roby::Task.new end end --> invalid replacement: missing provided models Roby2::Actions::Main::Move
- Loading branch information
Alexander Duda
authored and
Alexander Duda
committed
Dec 7, 2015
1 parent
f4213ba
commit d76b196
Showing
2 changed files
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,9 @@ def run(action_interface, arguments = Hash.new) | |
raise ArgumentError, "#{name} expects no arguments, but #{arguments.size} are given" | ||
end | ||
result = action_interface.send(name).as_plan | ||
if(!result.class.has_ancestor?(returned_type)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
doudou
Member
|
||
raise ArgumentError, "#{name} is expected to return #{returned_type} but returned #{result.class}" | ||
end | ||
else | ||
default_arguments = self.arguments.inject(Hash.new) do |h, arg| | ||
h[arg.name] = arg.default | ||
|
@@ -211,6 +214,9 @@ def run(action_interface, arguments = Hash.new) | |
end | ||
end | ||
result = action_interface.send(name, arguments).as_plan | ||
if(!result.class.has_ancestor?(returned_type)) | ||
raise ArgumentError, "#{name} is expected to return #{returned_type} but returned #{result.class}" | ||
end | ||
end | ||
# Make the planning task inherit the model/argument flags | ||
if planning_task = result.planning_task | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comment on style: don't parenthesis on
if(...)