mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
SocketCAN: Setting correct errno when throwing AllIfacesDownException
This commit is contained in:
parent
3d0186c547
commit
f86a4b98d1
@ -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) { }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user