SocketCAN: Setting correct errno when throwing AllIfacesDownException

This commit is contained in:
Pavel Kirienko 2016-01-28 01:06:29 +03:00
parent 3d0186c547
commit f86a4b98d1

View File

@ -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) { }
};
}