Skip to content

Commit 1726b87

Browse files
peterpeter
authored andcommitted
change misleading warning message, making it more correct and informative
Peter Mitrano (AR) <[email protected]>
1 parent a919a6e commit 1726b87

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

rclcpp_lifecycle/src/lifecycle_node_interface_impl.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ LifecycleNode::LifecycleNodeInterfaceImpl::change_state(
405405
// keep the initial state to pass to a transition callback
406406
initial_state = State(state_machine_.current_state);
407407

408+
const rcl_lifecycle_transition_t * const original_transition =
409+
rcl_lifecycle_get_transition_by_id(state_machine_.current_state, transition_id);
410+
411+
408412
if (
409413
rcl_lifecycle_trigger_transition_by_id(
410414
&state_machine_, transition_id, publish_update) != RCL_RET_OK)
@@ -459,12 +463,15 @@ LifecycleNode::LifecycleNodeInterfaceImpl::change_state(
459463
// Update the internal current_state_
460464
current_state_ = State(state_machine_.current_state);
461465

462-
// error handling ?!
466+
// error handling
463467
// TODO(karsten1987): iterate over possible ret value
464468
if (cb_return_code == node_interfaces::LifecycleNodeInterface::CallbackReturn::ERROR) {
465-
RCLCPP_WARN(
466-
node_logging_interface_->get_logger(),
467-
"Error occurred while doing error handling.");
469+
if (original_transition) {
470+
RCLCPP_WARN(
471+
node_logging_interface_->get_logger(),
472+
"Callback returned ERROR during the transition: %s", original_transition->label);
473+
}
474+
468475

469476
auto error_cb_code = execute_callback(current_state_id, initial_state);
470477
auto error_cb_label = get_label_for_return_code(error_cb_code);

0 commit comments

Comments
 (0)