mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 13:43:34 +08:00
SocketCAN: Proper error reporting from openSocket()
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace uavcan_linux
|
||||
@@ -16,9 +17,14 @@ class Exception : public std::runtime_error
|
||||
{
|
||||
const int errno_;
|
||||
|
||||
static std::string makeErrorString(const std::string& descr)
|
||||
{
|
||||
return descr + " [errno " + std::to_string(errno) + " \"" + std::strerror(errno) + "\"]";
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Exception(const std::string& descr)
|
||||
: std::runtime_error(descr)
|
||||
: std::runtime_error(makeErrorString(descr))
|
||||
, errno_(errno)
|
||||
{ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user