From 2d5afac3a6252c8a2afbee7acf8d767b4705b1fd Mon Sep 17 00:00:00 2001 From: William Woodall Date: Tue, 30 Jun 2015 11:54:40 -0700 Subject: [PATCH] use new rmw_get_error_string_safe func --- rclcpp/include/rclcpp/client.hpp | 2 +- rclcpp/include/rclcpp/node_impl.hpp | 12 ++++++------ rclcpp/include/rclcpp/publisher.hpp | 2 +- rclcpp/include/rclcpp/service.hpp | 2 +- rclcpp/include/rclcpp/subscription.hpp | 2 +- rclcpp/include/rclcpp/timer.hpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rclcpp/include/rclcpp/client.hpp b/rclcpp/include/rclcpp/client.hpp index 757bcb7..ee09193 100644 --- a/rclcpp/include/rclcpp/client.hpp +++ b/rclcpp/include/rclcpp/client.hpp @@ -59,7 +59,7 @@ public: if (rmw_destroy_client(client_handle_) == RMW_RET_ERROR) { // *INDENT-OFF* std::cerr << "Error in destruction of rmw client handle: " - << (rmw_get_error_string() ? rmw_get_error_string() : "") + << rmw_get_error_string_safe() << std::endl; // *INDENT-ON* } diff --git a/rclcpp/include/rclcpp/node_impl.hpp b/rclcpp/include/rclcpp/node_impl.hpp index be2d241..970ecdd 100644 --- a/rclcpp/include/rclcpp/node_impl.hpp +++ b/rclcpp/include/rclcpp/node_impl.hpp @@ -52,7 +52,7 @@ Node::Node(std::string node_name, context::Context::SharedPtr context) if (ret != RMW_RET_OK) { // *INDENT-OFF* std::cerr << "Error in destruction of rmw node handle: " - << (rmw_get_error_string() ? rmw_get_error_string() : "") + << rmw_get_error_string_safe() << std::endl; // *INDENT-ON* } @@ -62,7 +62,7 @@ Node::Node(std::string node_name, context::Context::SharedPtr context) // *INDENT-OFF* throw std::runtime_error( std::string("could not create node: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "")); + rmw_get_error_string_safe()); // *INDENT-ON* } @@ -97,7 +97,7 @@ Node::create_publisher(std::string topic_name, size_t queue_size) // *INDENT-OFF* (prevent uncrustify from making unecessary indents here) throw std::runtime_error( std::string("could not create publisher: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "")); + rmw_get_error_string_safe()); // *INDENT-ON* } @@ -135,7 +135,7 @@ Node::create_subscription( // *INDENT-OFF* (prevent uncrustify from making unecessary indents here) throw std::runtime_error( std::string("could not create subscription: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "")); + rmw_get_error_string_safe()); // *INDENT-ON* } @@ -209,7 +209,7 @@ Node::create_client( // *INDENT-OFF* (prevent uncrustify from making unecessary indents here) throw std::runtime_error( std::string("could not create client: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "")); + rmw_get_error_string_safe()); // *INDENT-ON* } @@ -252,7 +252,7 @@ Node::create_service( // *INDENT-OFF* (prevent uncrustify from making unecessary indents here) throw std::runtime_error( std::string("could not create service: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "")); + rmw_get_error_string_safe()); // *INDENT-ON* } diff --git a/rclcpp/include/rclcpp/publisher.hpp b/rclcpp/include/rclcpp/publisher.hpp index 42a8506..a16bbcb 100644 --- a/rclcpp/include/rclcpp/publisher.hpp +++ b/rclcpp/include/rclcpp/publisher.hpp @@ -50,7 +50,7 @@ public: if (rmw_destroy_publisher(node_handle_.get(), publisher_handle_) == RMW_RET_ERROR) { // *INDENT-OFF* std::cerr << "Error in destruction of rmw publisher handle: " - << (rmw_get_error_string() ? rmw_get_error_string() : "") + << rmw_get_error_string_safe() << std::endl; // *INDENT-ON* } diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 9141d48..0c54fff 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -57,7 +57,7 @@ public: if (service_handle_) { if (rmw_destroy_service(service_handle_) == RMW_RET_ERROR) { std::cerr << "Error in destruction of rmw service_handle_ handle: " << - (rmw_get_error_string() ? rmw_get_error_string() : "") << + rmw_get_error_string_safe() << std::endl; } } diff --git a/rclcpp/include/rclcpp/subscription.hpp b/rclcpp/include/rclcpp/subscription.hpp index de00b04..63a8fac 100644 --- a/rclcpp/include/rclcpp/subscription.hpp +++ b/rclcpp/include/rclcpp/subscription.hpp @@ -63,7 +63,7 @@ public: if (subscription_handle_) { if (rmw_destroy_subscription(node_handle_.get(), subscription_handle_) == RMW_RET_ERROR) { std::cerr << "Error in destruction of rmw subscription handle: " << - (rmw_get_error_string() ? rmw_get_error_string() : "") << + rmw_get_error_string_safe() << std::endl; } } diff --git a/rclcpp/include/rclcpp/timer.hpp b/rclcpp/include/rclcpp/timer.hpp index d87c71e..0eec801 100644 --- a/rclcpp/include/rclcpp/timer.hpp +++ b/rclcpp/include/rclcpp/timer.hpp @@ -58,7 +58,7 @@ public: // TODO(wjwwood): use custom exception throw std::runtime_error( std::string("failed to create guard condition: ") + - (rmw_get_error_string() ? rmw_get_error_string() : "") + rmw_get_error_string_safe() ); } } @@ -68,7 +68,7 @@ public: if (guard_condition_) { if (rmw_destroy_guard_condition(guard_condition_) == RMW_RET_ERROR) { std::cerr << "Error in TimerBase destructor, rmw_destroy_guard_condition failed: " << - (rmw_get_error_string() ? rmw_get_error_string() : "") << + rmw_get_error_string_safe() << std::endl; } }