[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 <brawner@gmail.com>

* Remove thrown error from reset and mark it no except

Signed-off-by: Stephen Brawner <brawner@gmail.com>

* Remove noexcept for ABI compatibility

Signed-off-by: Stephen Brawner <brawner@gmail.com>
This commit is contained in:
brawner 2020-10-05 15:44:55 -07:00 committed by GitHub
parent 45a47c6448
commit 6e6dd9cb1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -21,6 +21,7 @@
#include "rcl_lifecycle/rcl_lifecycle.h" #include "rcl_lifecycle/rcl_lifecycle.h"
#include "rclcpp/exceptions.hpp" #include "rclcpp/exceptions.hpp"
#include "rclcpp/logging.hpp"
#include "rcutils/allocator.h" #include "rcutils/allocator.h"
@ -157,7 +158,9 @@ State::reset()
allocator_.deallocate(state_handle_, allocator_.state); allocator_.deallocate(state_handle_, allocator_.state);
state_handle_ = nullptr; state_handle_ = nullptr;
if (ret != RCL_RET_OK) { 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");
} }
} }

View file

@ -21,6 +21,7 @@
#include "rcl_lifecycle/rcl_lifecycle.h" #include "rcl_lifecycle/rcl_lifecycle.h"
#include "rclcpp/exceptions.hpp" #include "rclcpp/exceptions.hpp"
#include "rclcpp/logging.hpp"
#include "rcutils/allocator.h" #include "rcutils/allocator.h"
@ -261,7 +262,9 @@ Transition::reset()
allocator_.deallocate(transition_handle_, allocator_.state); allocator_.deallocate(transition_handle_, allocator_.state);
transition_handle_ = nullptr; transition_handle_ = nullptr;
if (ret != RCL_RET_OK) { 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 } // namespace rclcpp_lifecycle