Skip to content

Commit c2ca00d

Browse files
authored
Same exact exception and what() message in both cases
1 parent cb738e0 commit c2ca00d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

rclcpp/src/rclcpp/node_interfaces/node_type_descriptions.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ class NodeTypeDescriptions::NodeTypeDescriptionsImpl
8585
logger_,
8686
"Invalid type '%s' for parameter 'start_type_description_service', should be 'bool'",
8787
rclcpp::to_string(enable_param.get_type()).c_str());
88-
throw std::invalid_argument(
89-
"Invalid type for parameter 'start_type_description_service', should be 'bool'");
88+
std::ostringstream ss;
89+
ss << "Wrong parameter type, parameter {" << enable_param_name << "} is of type {bool}, "
90+
<< "setting it to {" << to_string(enable_param.get_type()).c_str() << "} is not allowed.";
91+
throw rclcpp::exceptions::InvalidParameterTypeException(enable_param_name, ss.str());
9092
}
9193

9294
if (enable_param.get<bool>()) {

rclcpp/test/rclcpp/node_interfaces/test_node_type_descriptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ TEST_F(TestNodeTypeDescriptions, bad_parameter_type)
5656

5757
ASSERT_THROW(
5858
{
59+
node_options.automatically_declare_parameters_from_overrides(false);
5960
auto node = std::make_shared<rclcpp::Node>("node", "ns", node_options);
6061
(void) node;
6162
}, rclcpp::exceptions::InvalidParameterTypeException);
@@ -65,7 +66,7 @@ TEST_F(TestNodeTypeDescriptions, bad_parameter_type)
6566
node_options.automatically_declare_parameters_from_overrides(true);
6667
auto node = std::make_shared<rclcpp::Node>("node", "ns", node_options);
6768
(void) node;
68-
}, std::invalid_argument);
69+
}, rclcpp::exceptions::InvalidParameterTypeException);
6970
}
7071

7172
TEST_F(TestNodeTypeDescriptions, disabled_no_service)

0 commit comments

Comments
 (0)