diff --git a/rclcpp_lifecycle/src/lifecycle_node_interface_impl.hpp b/rclcpp_lifecycle/src/lifecycle_node_interface_impl.hpp index ef30855ac5..ea66d4ad54 100644 --- a/rclcpp_lifecycle/src/lifecycle_node_interface_impl.hpp +++ b/rclcpp_lifecycle/src/lifecycle_node_interface_impl.hpp @@ -333,10 +333,12 @@ class LifecycleNode::LifecycleNodeInterfaceImpl auto callback = it->second; try { cb_success = callback(State(previous_state)); - } catch (const std::exception & e) { - fprintf(stderr, "Caught exception in callback for transition %d\n", - it->first); - fprintf(stderr, "Original error msg: %s\n", e.what()); + } catch (const std::exception &) { + // TODO(karsten1987): Windows CI doens't let me print the msg here + // the todo is to forward the exception to the on_error callback + // fprintf(stderr, "Caught exception in callback for transition %d\n", + // it->first); + // fprintf(stderr, "Original error msg: %s\n", e.what()); // maybe directly go for error handling here // and pass exception along with it cb_success = RCL_LIFECYCLE_RET_ERROR; diff --git a/rclcpp_lifecycle/test/test_callback_exceptions.cpp b/rclcpp_lifecycle/test/test_callback_exceptions.cpp index c3450153cc..60fcfa2b89 100644 --- a/rclcpp_lifecycle/test/test_callback_exceptions.cpp +++ b/rclcpp_lifecycle/test/test_callback_exceptions.cpp @@ -49,13 +49,11 @@ class PositiveCallbackExceptionNode : public rclcpp_lifecycle::LifecycleNode rcl_lifecycle_ret_t on_configure(const rclcpp_lifecycle::State &) { ++number_of_callbacks; - throw std::runtime_error("On_configure exception"); + throw std::runtime_error("custom exception raised in configure callback"); } - rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State & previous_state) + rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State &) { - fprintf(stderr, "Previous state of error was %s\n", - previous_state.label().c_str()); ++number_of_callbacks; return RCL_LIFECYCLE_RET_OK; } @@ -84,13 +82,11 @@ class NegativeCallbackExceptionNode : public rclcpp_lifecycle::LifecycleNode rcl_lifecycle_ret_t on_configure(const rclcpp_lifecycle::State &) { ++number_of_callbacks; - throw std::runtime_error("On_configure exception"); + throw std::runtime_error("custom exception raised in configure callback"); } - rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State & previous_state) + rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State &) { - fprintf(stderr, "Previous state of error was %s\n", - previous_state.label().c_str()); ++number_of_callbacks; return RCL_LIFECYCLE_RET_FAILURE; }