use throw_from_rcl_error() for error state cleanup (#376)

This commit is contained in:
William Woodall 2017-09-19 14:13:28 -07:00 committed by GitHub
parent ca5fb57126
commit 5813ba54db

View file

@ -20,6 +20,7 @@
#include "rcl/allocator.h"
#include "rcl/error_handling.h"
#include "rclcpp/exceptions.hpp"
#include "rclcpp/executor.hpp"
#include "rclcpp/node.hpp"
#include "rclcpp/scope_exit.hpp"
@ -418,10 +419,8 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout)
if (status == RCL_RET_WAIT_SET_EMPTY) {
fprintf(stderr, "Warning: empty waitset received in rcl_wait(). This should never happen.\n");
} else if (status != RCL_RET_OK && status != RCL_RET_TIMEOUT) {
std::string msg = "rcl_wait() failed: ";
msg += rcl_get_error_string_safe();
rcl_reset_error();
throw std::runtime_error(msg);
using rclcpp::exceptions::throw_from_rcl_error;
throw_from_rcl_error(status, "rcl_wait() failed");
}
// check the null handles in the waitset and remove them from the handles in memory strategy