USRP Hardware Driver and USRP Manual
Version: 3.15.0.0-2+b1
UHD and USRP Manual
error.h
Go to the documentation of this file.
1
/*
2
* Copyright 2015 Ettus Research LLC
3
* Copyright 2018 Ettus Research, a National Instruments Company
4
*
5
* SPDX-License-Identifier: GPL-3.0-or-later
6
*/
7
8
#ifndef INCLUDED_UHD_ERROR_H
9
#define INCLUDED_UHD_ERROR_H
10
11
#include <stdlib.h>
12
14
21
typedef
enum
{
22
24
UHD_ERROR_NONE
= 0,
26
UHD_ERROR_INVALID_DEVICE
= 1,
27
29
UHD_ERROR_INDEX
= 10,
31
UHD_ERROR_KEY
= 11,
32
34
UHD_ERROR_NOT_IMPLEMENTED
= 20,
36
UHD_ERROR_USB
= 21,
37
39
UHD_ERROR_IO
= 30,
41
UHD_ERROR_OS
= 31,
42
44
UHD_ERROR_ASSERTION
= 40,
46
UHD_ERROR_LOOKUP
= 41,
48
UHD_ERROR_TYPE
= 42,
50
UHD_ERROR_VALUE
= 43,
52
UHD_ERROR_RUNTIME
= 44,
54
UHD_ERROR_ENVIRONMENT
= 45,
56
UHD_ERROR_SYSTEM
= 46,
58
UHD_ERROR_EXCEPT
= 47,
59
61
UHD_ERROR_BOOSTEXCEPT
= 60,
62
64
UHD_ERROR_STDEXCEPT
= 70,
65
67
UHD_ERROR_UNKNOWN
= 100
68
}
uhd_error
;
69
70
#ifdef __cplusplus
71
#include <
uhd/config.hpp
>
72
#include <
uhd/exception.hpp
>
73
74
#include <boost/exception/diagnostic_information.hpp>
75
76
#include <string>
77
78
UHD_API
uhd_error
error_from_uhd_exception(
const
uhd::exception
* e);
79
81
UHD_API
std::string get_c_global_error_string();
82
83
UHD_API
void
set_c_global_error_string(
const
std::string &msg);
84
90
#define UHD_SAFE_C(...) \
91
try{ __VA_ARGS__ } \
92
catch (const uhd::exception &e) { \
93
set_c_global_error_string(e.what()); \
94
return error_from_uhd_exception(&e); \
95
} \
96
catch (const boost::exception &e) { \
97
set_c_global_error_string(boost::diagnostic_information(e)); \
98
return UHD_ERROR_BOOSTEXCEPT; \
99
} \
100
catch (const std::exception &e) { \
101
set_c_global_error_string(e.what()); \
102
return UHD_ERROR_STDEXCEPT; \
103
} \
104
catch (...) { \
105
set_c_global_error_string("Unrecognized exception caught."); \
106
return UHD_ERROR_UNKNOWN; \
107
} \
108
set_c_global_error_string("None"); \
109
return UHD_ERROR_NONE;
110
116
#define UHD_SAFE_C_SAVE_ERROR(h, ...) \
117
h->last_error.clear(); \
118
try{ __VA_ARGS__ } \
119
catch (const uhd::exception &e) { \
120
set_c_global_error_string(e.what()); \
121
h->last_error = e.what(); \
122
return error_from_uhd_exception(&e); \
123
} \
124
catch (const boost::exception &e) { \
125
set_c_global_error_string(boost::diagnostic_information(e)); \
126
h->last_error = boost::diagnostic_information(e); \
127
return UHD_ERROR_BOOSTEXCEPT; \
128
} \
129
catch (const std::exception &e) { \
130
set_c_global_error_string(e.what()); \
131
h->last_error = e.what(); \
132
return UHD_ERROR_STDEXCEPT; \
133
} \
134
catch (...) { \
135
set_c_global_error_string("Unrecognized exception caught."); \
136
h->last_error = "Unrecognized exception caught."; \
137
return UHD_ERROR_UNKNOWN; \
138
} \
139
h->last_error = "None"; \
140
set_c_global_error_string("None"); \
141
return UHD_ERROR_NONE;
142
143
extern
"C"
{
144
#endif
145
147
152
UHD_API
uhd_error
uhd_get_last_error
(
153
char
* error_out,
154
size_t
strbuffer_len
155
);
156
#ifdef __cplusplus
157
}
158
#endif
159
160
#endif
/* INCLUDED_UHD_ERROR_H */
UHD_ERROR_SYSTEM
See uhd::system_error.
Definition:
error.h:56
UHD_ERROR_ASSERTION
See uhd::assertion_error.
Definition:
error.h:44
config.hpp
UHD_ERROR_EXCEPT
See uhd::exception.
Definition:
error.h:58
UHD_ERROR_UNKNOWN
An unknown error was thrown.
Definition:
error.h:67
uhd::exception
Definition:
exception.hpp:37
UHD_ERROR_RUNTIME
See uhd::runtime_error.
Definition:
error.h:52
uhd_error
uhd_error
UHD error codes.
Definition:
error.h:21
uhd_get_last_error
UHD_API uhd_error uhd_get_last_error(char *error_out, size_t strbuffer_len)
Return the last error string reported by UHD.
UHD_ERROR_OS
See uhd::os_error.
Definition:
error.h:41
UHD_ERROR_LOOKUP
See uhd::lookup_error.
Definition:
error.h:46
UHD_ERROR_ENVIRONMENT
See uhd::environment_error.
Definition:
error.h:54
UHD_ERROR_IO
See uhd::io_error.
Definition:
error.h:39
UHD_ERROR_BOOSTEXCEPT
A boost::exception was thrown.
Definition:
error.h:61
UHD_API
#define UHD_API
Definition:
config.h:68
UHD_ERROR_NONE
No error thrown.
Definition:
error.h:24
UHD_ERROR_VALUE
See uhd::value_error.
Definition:
error.h:50
UHD_ERROR_KEY
See uhd::key_error.
Definition:
error.h:31
UHD_ERROR_USB
See uhd::usb_error.
Definition:
error.h:36
UHD_ERROR_INDEX
See uhd::index_error.
Definition:
error.h:29
UHD_ERROR_NOT_IMPLEMENTED
See uhd::not_implemented_error.
Definition:
error.h:34
UHD_ERROR_TYPE
See uhd::type_error.
Definition:
error.h:48
exception.hpp
UHD_ERROR_STDEXCEPT
A std::exception was thrown.
Definition:
error.h:64
UHD_ERROR_INVALID_DEVICE
Invalid device arguments.
Definition:
error.h:26
include
uhd
error.h
Generated by
1.8.16