USRP Hardware Driver and USRP Manual Version: 3.15.0.0-MacPorts-Release
UHD and USRP Manual
 
Loading...
Searching...
No Matches
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
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
78UHD_API uhd_error error_from_uhd_exception(const uhd::exception* e);
79
81UHD_API std::string get_c_global_error_string();
82
83UHD_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
143extern "C" {
144#endif
145
147
153 char* error_out,
154 size_t strbuffer_len
155);
156#ifdef __cplusplus
157}
158#endif
159
160#endif /* INCLUDED_UHD_ERROR_H */
#define UHD_API
Definition config.h:68
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
UHD error codes.
Definition error.h:21
@ UHD_ERROR_BOOSTEXCEPT
A boost::exception was thrown.
Definition error.h:61
@ UHD_ERROR_OS
See uhd::os_error.
Definition error.h:41
@ UHD_ERROR_ASSERTION
See uhd::assertion_error.
Definition error.h:44
@ UHD_ERROR_STDEXCEPT
A std::exception was thrown.
Definition error.h:64
@ UHD_ERROR_INDEX
See uhd::index_error.
Definition error.h:29
@ UHD_ERROR_NONE
No error thrown.
Definition error.h:24
@ UHD_ERROR_VALUE
See uhd::value_error.
Definition error.h:50
@ UHD_ERROR_IO
See uhd::io_error.
Definition error.h:39
@ UHD_ERROR_NOT_IMPLEMENTED
See uhd::not_implemented_error.
Definition error.h:34
@ UHD_ERROR_LOOKUP
See uhd::lookup_error.
Definition error.h:46
@ UHD_ERROR_EXCEPT
See uhd::exception.
Definition error.h:58
@ UHD_ERROR_KEY
See uhd::key_error.
Definition error.h:31
@ UHD_ERROR_RUNTIME
See uhd::runtime_error.
Definition error.h:52
@ UHD_ERROR_TYPE
See uhd::type_error.
Definition error.h:48
@ UHD_ERROR_INVALID_DEVICE
Invalid device arguments.
Definition error.h:26
@ UHD_ERROR_UNKNOWN
An unknown error was thrown.
Definition error.h:67
@ UHD_ERROR_USB
See uhd::usb_error.
Definition error.h:36
@ UHD_ERROR_ENVIRONMENT
See uhd::environment_error.
Definition error.h:54
@ UHD_ERROR_SYSTEM
See uhd::system_error.
Definition error.h:56
Definition exception.hpp:38