Skip to content

Commit

Permalink
Use InvalidParameterTypeException
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammad Farzan <m2_farzan@yahoo.com>
  • Loading branch information
m2-farzan committed Jun 8, 2021
1 parent 7d8b269 commit df43aa1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions rclcpp/include/rclcpp/node_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,16 @@ Node::declare_parameter(
// get advantage of parameter value template magic to get
// the correct rclcpp::ParameterType from ParameterT
rclcpp::ParameterValue value{ParameterT{}};
return this->declare_parameter(
name,
value.get_type(),
parameter_descriptor,
ignore_override
).get<ParameterT>();
try {
return this->declare_parameter(
name,
value.get_type(),
parameter_descriptor,
ignore_override
).get<ParameterT>();
} catch (const ParameterTypeException & ex) {
throw exceptions::InvalidParameterTypeException(name, ex.what());
}
}

template<typename ParameterT>
Expand Down

0 comments on commit df43aa1

Please sign in to comment.