Skip to content

Commit 0036533

Browse files
mergify[bot]mleegwtfujitatomoyaahcorde
authored
Fix: improve exception context for parameter_value_from (backport #2917) (#2921)
Signed-off-by: Michiel Leegwater <[email protected]> Signed-off-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Alejandro Hernandez Cordero <[email protected]> Co-authored-by: Michiel Leegwater <[email protected]> Co-authored-by: Tomoya Fujita <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]>
1 parent 76cdd45 commit 0036533

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rclcpp/src/rclcpp/parameter_map.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,15 @@ rclcpp::parameter_map_from(const rcl_params_t * const c_params, const char * nod
8181
throw InvalidParametersException(message);
8282
}
8383
const rcl_variant_t * const c_param_value = &(c_params_node->parameter_values[p]);
84-
params_node.emplace_back(c_param_name, parameter_value_from(c_param_value));
84+
ParameterValue value;
85+
try {
86+
value = parameter_value_from(c_param_value);
87+
} catch (const InvalidParameterValueException & e) {
88+
throw InvalidParameterValueException(
89+
std::string("parameter_value_from failed for parameter '") +
90+
c_param_name + "': " + e.what());
91+
}
92+
params_node.emplace_back(c_param_name, value);
8593
}
8694
}
8795

0 commit comments

Comments
 (0)