Files
PX4-Autopilot/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp
T
Pavel Kirienko 587088bb18 Refactored SocketCAN select() call; fixes #83
Features:
- The driver will throw if it's fed a non-existing or malfunctioning interface during initialization
- When an interface becomes down/disconnected while the node is running, the driver will silently
  exclude it from the IO loop and continue to run on the remaining interfaces.
- When all interfaces become down/disconnected, the driver will throw AllIfacesDownException() from
  SocketCanDriver::select().
2016-01-28 00:12:27 +03:00

42 lines
851 B
C++

/*
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#include <cerrno>
#include <stdexcept>
namespace uavcan_linux
{
/**
* This is the root exception class for all exceptions that can be thrown from the libuavcan Linux driver.
*/
class Exception : public std::runtime_error
{
const int errno_;
public:
explicit Exception(const std::string& descr)
: std::runtime_error(descr)
, errno_(errno)
{ }
/**
* Returns standard UNIX errno value captured at the moment
* when this exception object was constructed.
*/
int getErrno() const { return errno_; }
};
/**
* This exception is thrown when all available interfaces become down.
*/
class AllIfacesDownException : public Exception
{
public:
AllIfacesDownException() : Exception("All ifaces are down") { }
};
}