mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 16:13:34 +08:00
SocketCAN: Setting correct errno when throwing AllIfacesDownException
This commit is contained in:
@@ -17,15 +17,15 @@ class Exception : public std::runtime_error
|
|||||||
{
|
{
|
||||||
const int errno_;
|
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:
|
public:
|
||||||
explicit Exception(const std::string& descr)
|
explicit Exception(const std::string& descr, int use_errno = errno)
|
||||||
: std::runtime_error(makeErrorString(descr))
|
: std::runtime_error(makeErrorString(descr, use_errno))
|
||||||
, errno_(errno)
|
, errno_(use_errno)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
class AllIfacesDownException : public Exception
|
class AllIfacesDownException : public Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AllIfacesDownException() : Exception("All ifaces are down") { }
|
AllIfacesDownException() : Exception("All ifaces are down", ENETDOWN) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user