From 5813ba54db8e975e1f3f256ba34614ed62356ec2 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Tue, 19 Sep 2017 14:13:28 -0700 Subject: [PATCH] use throw_from_rcl_error() for error state cleanup (#376) --- rclcpp/src/rclcpp/executor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 6cc7905..c56c470 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -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