8 #ifndef INCLUDED_UHD_ERROR_H
9 #define INCLUDED_UHD_ERROR_H
74 #include <boost/exception/diagnostic_information.hpp>
81 UHD_API std::string get_c_global_error_string();
83 UHD_API void set_c_global_error_string(
const std::string &msg);
90 #define UHD_SAFE_C(...) \
92 catch (const uhd::exception &e) { \
93 set_c_global_error_string(e.what()); \
94 return error_from_uhd_exception(&e); \
96 catch (const boost::exception &e) { \
97 set_c_global_error_string(boost::diagnostic_information(e)); \
98 return UHD_ERROR_BOOSTEXCEPT; \
100 catch (const std::exception &e) { \
101 set_c_global_error_string(e.what()); \
102 return UHD_ERROR_STDEXCEPT; \
105 set_c_global_error_string("Unrecognized exception caught."); \
106 return UHD_ERROR_UNKNOWN; \
108 set_c_global_error_string("None"); \
109 return UHD_ERROR_NONE;
116 #define UHD_SAFE_C_SAVE_ERROR(h, ...) \
117 h->last_error.clear(); \
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); \
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; \
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; \
135 set_c_global_error_string("Unrecognized exception caught."); \
136 h->last_error = "Unrecognized exception caught."; \
137 return UHD_ERROR_UNKNOWN; \
139 h->last_error = "None"; \
140 set_c_global_error_string("None"); \
141 return UHD_ERROR_NONE;
#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