Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
/*
* Copyright 2015 Ettus Research LLC
* Copyright 2018 Ettus Research, a National Instruments Company
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <stdlib.h>
typedef enum {
UHD_ERROR_NONE = 0,
UHD_ERROR_INVALID_DEVICE = 1,
UHD_ERROR_INDEX = 10,
UHD_ERROR_KEY = 11,
UHD_ERROR_NOT_IMPLEMENTED = 20,
UHD_ERROR_USB = 21,
UHD_ERROR_IO = 30,
UHD_ERROR_OS = 31,
UHD_ERROR_ASSERTION = 40,
UHD_ERROR_LOOKUP = 41,
UHD_ERROR_TYPE = 42,
UHD_ERROR_VALUE = 43,
UHD_ERROR_RUNTIME = 44,
UHD_ERROR_ENVIRONMENT = 45,
UHD_ERROR_SYSTEM = 46,
UHD_ERROR_EXCEPT = 47,
UHD_ERROR_BOOSTEXCEPT = 60,
UHD_ERROR_STDEXCEPT = 70,
UHD_ERROR_UNKNOWN = 100
} uhd_error;
#ifdef __cplusplus
# include <uhd/config.hpp>
# include <uhd/exception.hpp>
# include <boost/exception/diagnostic_information.hpp>
# include <string>
UHD_API uhd_error error_from_uhd_exception(const uhd::exception* e);
UHD_API std::string get_c_global_error_string();
UHD_API void set_c_global_error_string(const std::string& msg);
# define UHD_SAFE_C(...) \
try { \
__VA_ARGS__ \
} catch (const uhd::exception& e) { \
set_c_global_error_string(e.what()); \
return error_from_uhd_exception(&e); \
} catch (const boost::exception& e) { \
set_c_global_error_string(boost::diagnostic_information(e)); \
return UHD_ERROR_BOOSTEXCEPT; \
} catch (const std::exception& e) { \
set_c_global_error_string(e.what()); \
return UHD_ERROR_STDEXCEPT; \
} catch (...) { \
set_c_global_error_string("Unrecognized exception caught."); \
return UHD_ERROR_UNKNOWN; \
} \
set_c_global_error_string("None"); \
return UHD_ERROR_NONE;
# define UHD_SAFE_C_SAVE_ERROR(h, ...) \
h->last_error.clear(); \
try { \
__VA_ARGS__ \
} catch (const uhd::exception& e) { \
set_c_global_error_string(e.what()); \
h->last_error = e.what(); \
return error_from_uhd_exception(&e); \
} catch (const boost::exception& e) { \
set_c_global_error_string(boost::diagnostic_information(e)); \
h->last_error = boost::diagnostic_information(e); \
return UHD_ERROR_BOOSTEXCEPT; \
} catch (const std::exception& e) { \
set_c_global_error_string(e.what()); \
h->last_error = e.what(); \
return UHD_ERROR_STDEXCEPT; \
} catch (...) { \
set_c_global_error_string("Unrecognized exception caught."); \
h->last_error = "Unrecognized exception caught."; \
return UHD_ERROR_UNKNOWN; \
} \
h->last_error = "None"; \
set_c_global_error_string("None"); \
return UHD_ERROR_NONE;
extern "C" {
#endif
UHD_API uhd_error uhd_get_last_error(char* error_out, size_t strbuffer_len);
#ifdef __cplusplus
}
#endif
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
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
uhd_error
UHD error codes.
Definition error.h:20
UHD_ERROR_BOOSTEXCEPT
@ UHD_ERROR_BOOSTEXCEPT
A boost::exception was thrown.
Definition error.h:60
UHD_ERROR_OS
@ UHD_ERROR_OS
See uhd::os_error.
Definition error.h:40
UHD_ERROR_ASSERTION
@ UHD_ERROR_ASSERTION
See uhd::assertion_error.
Definition error.h:43
UHD_ERROR_STDEXCEPT
@ UHD_ERROR_STDEXCEPT
A std::exception was thrown.
Definition error.h:63
UHD_ERROR_INDEX
@ UHD_ERROR_INDEX
See uhd::index_error.
Definition error.h:28
UHD_ERROR_NONE
@ UHD_ERROR_NONE
No error thrown.
Definition error.h:23
UHD_ERROR_VALUE
@ UHD_ERROR_VALUE
See uhd::value_error.
Definition error.h:49
UHD_ERROR_IO
@ UHD_ERROR_IO
See uhd::io_error.
Definition error.h:38
UHD_ERROR_NOT_IMPLEMENTED
@ UHD_ERROR_NOT_IMPLEMENTED
See uhd::not_implemented_error.
Definition error.h:33
UHD_ERROR_LOOKUP
@ UHD_ERROR_LOOKUP
See uhd::lookup_error.
Definition error.h:45
UHD_ERROR_EXCEPT
@ UHD_ERROR_EXCEPT
See uhd::exception.
Definition error.h:57
UHD_ERROR_KEY
@ UHD_ERROR_KEY
See uhd::key_error.
Definition error.h:30
UHD_ERROR_RUNTIME
@ UHD_ERROR_RUNTIME
See uhd::runtime_error.
Definition error.h:51
UHD_ERROR_TYPE
@ UHD_ERROR_TYPE
See uhd::type_error.
Definition error.h:47
UHD_ERROR_INVALID_DEVICE
@ UHD_ERROR_INVALID_DEVICE
Invalid device arguments.
Definition error.h:25
UHD_ERROR_UNKNOWN
@ UHD_ERROR_UNKNOWN
An unknown error was thrown.
Definition error.h:66
UHD_ERROR_USB
@ UHD_ERROR_USB
See uhd::usb_error.
Definition error.h:35
UHD_ERROR_ENVIRONMENT
@ UHD_ERROR_ENVIRONMENT
See uhd::environment_error.
Definition error.h:53
UHD_ERROR_SYSTEM
@ UHD_ERROR_SYSTEM
See uhd::system_error.
Definition error.h:55
exception.hpp
uhd::exception
Definition exception.hpp:36