libs
platform_specific_components
linux
libuavcan
include
uavcan_linux
exception.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
3
*/
4
5
#pragma once
6
7
#include <cerrno>
8
#include <cstring>
9
#include <stdexcept>
10
11
namespace
uavcan_linux
12
{
16
class
Exception
:
public
std::runtime_error
17
{
18
const
int
errno_
;
19
20
static
std::string
makeErrorString
(
const
std::string& descr,
int
use_errno)
21
{
22
return
descr +
" [errno "
+ std::to_string(use_errno) +
" \""
+ std::strerror(use_errno) +
"\"]"
;
23
}
24
25
public
:
26
explicit
Exception
(
const
std::string& descr,
int
use_errno = errno)
27
:
std
::runtime_error(
makeErrorString
(descr, use_errno))
28
,
errno_
(use_errno)
29
{ }
30
35
int
getErrno
()
const
{
return
errno_
; }
36
};
37
42
class
LibuavcanErrorException
:
public
Exception
43
{
44
const
std::int16_t
error_
;
45
46
static
std::string
makeErrorString
(
std::int16_t
e)
47
{
48
return
"Libuavcan error ("
+ std::to_string(e) +
")"
;
49
}
50
51
public
:
52
explicit
LibuavcanErrorException
(
std::int16_t
uavcan_error_code) :
53
Exception
(
makeErrorString
(uavcan_error_code)),
54
error_
(
std
::abs(uavcan_error_code))
55
{ }
56
57
std::int16_t
getLibuavcanErrorCode
()
const
{
return
error_
; }
58
};
59
63
class
AllIfacesDownException
:
public
Exception
64
{
65
public
:
66
AllIfacesDownException
() :
Exception
(
"All ifaces are down"
, ENETDOWN) { }
67
};
68
69
}
uavcan_linux::AllIfacesDownException::AllIfacesDownException
AllIfacesDownException()
Definition:
exception.hpp:66
uavcan_linux::AllIfacesDownException
Definition:
exception.hpp:63
uavcan_linux::LibuavcanErrorException::getLibuavcanErrorCode
std::int16_t getLibuavcanErrorCode() const
Definition:
exception.hpp:57
uavcan_linux::Exception::Exception
Exception(const std::string &descr, int use_errno=errno)
Definition:
exception.hpp:26
uavcan::int16_t
std::int16_t int16_t
Definition:
std.hpp:30
uavcan_linux::Exception::errno_
const int errno_
Definition:
exception.hpp:18
uavcan_linux::Exception
Definition:
exception.hpp:16
uavcan_linux::Exception::makeErrorString
static std::string makeErrorString(const std::string &descr, int use_errno)
Definition:
exception.hpp:20
uavcan_linux::LibuavcanErrorException
Definition:
exception.hpp:42
uavcan_linux::LibuavcanErrorException::makeErrorString
static std::string makeErrorString(std::int16_t e)
Definition:
exception.hpp:46
uavcan_linux::Exception::getErrno
int getErrno() const
Definition:
exception.hpp:35
uavcan_linux
Definition:
platform_specific_components/linux/libuavcan/include/uavcan_linux/clock.hpp:18
std
uavcan_linux::LibuavcanErrorException::error_
const std::int16_t error_
Definition:
exception.hpp:44
uavcan_linux::LibuavcanErrorException::LibuavcanErrorException
LibuavcanErrorException(std::int16_t uavcan_error_code)
Definition:
exception.hpp:52
uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:02