From 6e6dd9cb1ae7856987bde00e8750e4608ae3edc1 Mon Sep 17 00:00:00 2001 From: brawner Date: Mon, 5 Oct 2020 15:44:55 -0700 Subject: [PATCH] [backport foxy] Log error instead of throwing exception in Transition and State reset() mark no except (#1297) (#1378) * Log error instead of throwing exception in Transition and State reset(), mark no except (#1297) * Catch potential exception in destructor and log Signed-off-by: Stephen Brawner * Remove thrown error from reset and mark it no except Signed-off-by: Stephen Brawner * Remove noexcept for ABI compatibility Signed-off-by: Stephen Brawner --- rclcpp_lifecycle/src/state.cpp | 5 ++++- rclcpp_lifecycle/src/transition.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rclcpp_lifecycle/src/state.cpp b/rclcpp_lifecycle/src/state.cpp index 7024a82..5ed6aa7 100644 --- a/rclcpp_lifecycle/src/state.cpp +++ b/rclcpp_lifecycle/src/state.cpp @@ -21,6 +21,7 @@ #include "rcl_lifecycle/rcl_lifecycle.h" #include "rclcpp/exceptions.hpp" +#include "rclcpp/logging.hpp" #include "rcutils/allocator.h" @@ -157,7 +158,9 @@ State::reset() allocator_.deallocate(state_handle_, allocator_.state); state_handle_ = nullptr; if (ret != RCL_RET_OK) { - rclcpp::exceptions::throw_from_rcl_error(ret); + RCLCPP_ERROR( + rclcpp::get_logger("rclcpp_lifecycle"), + "rcl_lifecycle_transition_fini did not complete successfully, leaking memory"); } } diff --git a/rclcpp_lifecycle/src/transition.cpp b/rclcpp_lifecycle/src/transition.cpp index cb7d471..a76b4c1 100644 --- a/rclcpp_lifecycle/src/transition.cpp +++ b/rclcpp_lifecycle/src/transition.cpp @@ -21,6 +21,7 @@ #include "rcl_lifecycle/rcl_lifecycle.h" #include "rclcpp/exceptions.hpp" +#include "rclcpp/logging.hpp" #include "rcutils/allocator.h" @@ -261,7 +262,9 @@ Transition::reset() allocator_.deallocate(transition_handle_, allocator_.state); transition_handle_ = nullptr; if (ret != RCL_RET_OK) { - rclcpp::exceptions::throw_from_rcl_error(ret); + RCLCPP_ERROR( + rclcpp::get_logger("rclcpp_lifecycle"), + "rcl_lifecycle_transition_fini did not complete successfully, leaking memory"); } } } // namespace rclcpp_lifecycle