Skip to content

Commit 591a8af

Browse files
authored
check that passed type is actually a service (#559)
Signed-off-by: Dirk Thomas <[email protected]>
1 parent 26737ae commit 591a8af

File tree

1 file changed

+6
-3
lines changed
  • ros2service/ros2service/verb

1 file changed

+6
-3
lines changed

ros2service/ros2service/verb/call.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ def requester(service_type, service_name, values, period):
6969
module = importlib.import_module('.'.join(parts[:-1]))
7070
srv_name = parts[-1]
7171
srv_module = getattr(module, srv_name)
72-
if not package_name or not srv_module:
73-
raise ValueError()
74-
except ValueError:
72+
except (AttributeError, ModuleNotFoundError, ValueError):
7573
raise RuntimeError('The passed service type is invalid')
74+
try:
75+
srv_module.Request
76+
srv_module.Response
77+
except AttributeError:
78+
raise RuntimeError('The passed type is not a service')
7679

7780
values_dictionary = yaml.safe_load(values)
7881

0 commit comments

Comments
 (0)