From 6828982e9c381fbf35860c4296a4f1133c8b0d37 Mon Sep 17 00:00:00 2001 From: Ferry Schoenmakers Date: Fri, 28 Jun 2024 13:01:21 +0200 Subject: [PATCH] Don't hard exit on send failures, but do notify the user --- src/socketcan_bridge.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/socketcan_bridge.cpp b/src/socketcan_bridge.cpp index 146aa31..7526bfb 100644 --- a/src/socketcan_bridge.cpp +++ b/src/socketcan_bridge.cpp @@ -56,7 +56,8 @@ void SocketCanBridge::send(const can_msgs::msg::Frame & msg) const RCLCPP_DEBUG_STREAM(logger_, "Sending " << msg); auto n = write(socket_, &frame, sizeof(frame)); if (n < 0) { - throw std::system_error(errno, std::generic_category()); + RCLCPP_ERROR_THROTTLE( + logger_, *clock_, 5000, "Error writing to the socket: %s (%d)", strerror(errno), errno); } RCLCPP_DEBUG(logger_, "Wrote %zd bytes to the socket", n); }