Skip to content

Commit e677f4c

Browse files
authored
Adressed TODO in node_graph (#2877)
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
1 parent 5122c31 commit e677f4c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

rclcpp/src/rclcpp/node_interfaces/node_graph.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ NodeGraph::get_node_names_and_namespaces() const
419419
rcl_get_error_string().str;
420420
rcl_reset_error();
421421
}
422-
// TODO(karsten1987): Append rcutils_error_message once it's in master
422+
RCUTILS_LOG_ERROR_NAMED("rclcpp", error_msg.c_str());
423423
throw std::runtime_error(error_msg);
424424
}
425425

@@ -434,20 +434,15 @@ NodeGraph::get_node_names_and_namespaces() const
434434
std::string error;
435435
rcl_ret_t ret_names = rcutils_string_array_fini(&node_names_c);
436436
if (ret_names != RCUTILS_RET_OK) {
437-
// *INDENT-OFF*
438-
// TODO(karsten1987): Append rcutils_error_message once it's in master
439-
error = "could not destroy node names";
440-
// *INDENT-ON*
437+
error = std::string("could not destroy node names: ") + rcl_get_error_string().str;
441438
}
442439
rcl_ret_t ret_ns = rcutils_string_array_fini(&node_namespaces_c);
443440
if (ret_ns != RCUTILS_RET_OK) {
444-
// *INDENT-OFF*
445-
// TODO(karsten1987): Append rcutils_error_message once it's in master
446-
error += ", could not destroy node namespaces";
447-
// *INDENT-ON*
441+
error += std::string(", could not destroy node namespaces: ") + rcl_get_error_string().str;
448442
}
449443

450444
if (ret_names != RCUTILS_RET_OK || ret_ns != RCUTILS_RET_OK) {
445+
RCUTILS_LOG_ERROR_NAMED("rclcpp", error.c_str());
451446
throw std::runtime_error(error);
452447
}
453448

rclcpp/test/rclcpp/node_interfaces/test_node_graph.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ TEST_F(TestNodeGraph, get_node_names_and_namespaces_fini_errors)
510510
"lib:rclcpp", rcutils_string_array_fini, RCL_RET_ERROR);
511511
RCLCPP_EXPECT_THROW_EQ(
512512
node_graph()->get_node_names_and_namespaces(),
513-
std::runtime_error("could not destroy node names, could not destroy node namespaces"));
513+
std::runtime_error(
514+
"could not destroy node names: error not set, "
515+
"could not destroy node namespaces: error not set"));
514516
}
515517

516518
TEST_F(TestNodeGraph, get_node_names_with_enclaves_fini_errors)

0 commit comments

Comments
 (0)