Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve evaluate_paramenter_dict exceptions error message #320

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions launch_ros/launch_ros/utilities/evaluate_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,20 @@ def check_sequence_type_is_allowed(sequence):
if not check_sequence_type_is_allowed(yaml_evaluated_value):
raise TypeError(
'Expected a non-empty sequence, with items of uniform type. '
'Allowed sequence item types are bool, int, float, str.'
'Allowed sequence item types are bool, int, float, str. '
'Got inconsistent input for "{}"'.format(evaluated_name)
)
evaluated_value = tuple(yaml_evaluated_value)
else:
raise TypeError(
'Allowed value types are bytes, bool, int, float, str, Sequence[bool]'
', Sequence[int], Sequence[float], Sequence[str]. Got {}.'
', Sequence[int], Sequence[float], Sequence[str]. Got {} for "{}". '
'If the parameter is meant to be a string, try wrapping it in '
'launch_ros.parameter_descriptions.ParameterValue'
'(value, value_type=str)'.format(type(yaml_evaluated_value))
'(value, value_type=str)'.format(
type(yaml_evaluated_value),
evaluated_name
)
)
elif isinstance(value[0], Sequence):
# Value is an array of a list of substitutions
Expand All @@ -119,7 +123,8 @@ def check_sequence_type_is_allowed(sequence):
if not check_sequence_type_is_allowed(yaml_evaluated_value):
raise TypeError(
'Expected a non-empty sequence, with items of uniform type. '
'Allowed sequence item types are bool, int, float, str.'
'Allowed sequence item types are bool, int, float, str. '
'Got inconsistent input for "{}"'.format(evaluated_name)
)
evaluated_value = tuple(yaml_evaluated_value)
else:
Expand Down