SocketCAN: Proper error reporting from openSocket()

This commit is contained in:
Pavel Kirienko
2016-01-28 00:50:28 +03:00
parent 587088bb18
commit 597e0b4356
2 changed files with 49 additions and 19 deletions
@@ -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)
{ }