From f86a4b98d199c7bdecaed1db463e79d6f719df2b Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 28 Jan 2016 01:06:29 +0300 Subject: [PATCH] SocketCAN: Setting correct errno when throwing AllIfacesDownException --- .../linux/include/uavcan_linux/exception.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp b/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp index e6fc8ba111..394da2a816 100644 --- a/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp +++ b/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp @@ -17,15 +17,15 @@ class Exception : public std::runtime_error { const int errno_; - static std::string makeErrorString(const std::string& descr) + static std::string makeErrorString(const std::string& descr, int use_errno) { - return descr + " [errno " + std::to_string(errno) + " \"" + std::strerror(errno) + "\"]"; + return descr + " [errno " + std::to_string(use_errno) + " \"" + std::strerror(use_errno) + "\"]"; } public: - explicit Exception(const std::string& descr) - : std::runtime_error(makeErrorString(descr)) - , errno_(errno) + explicit Exception(const std::string& descr, int use_errno = errno) + : std::runtime_error(makeErrorString(descr, use_errno)) + , errno_(use_errno) { } /** @@ -41,7 +41,7 @@ public: class AllIfacesDownException : public Exception { public: - AllIfacesDownException() : Exception("All ifaces are down") { } + AllIfacesDownException() : Exception("All ifaces are down", ENETDOWN) { } }; }