USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-ga1b5c4ae
UHD and USRP Manual
safe_call.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 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_UTILS_SAFE_CALL_HPP
9 #define INCLUDED_UHD_UTILS_SAFE_CALL_HPP
10 
11 #include <uhd/config.hpp>
12 #include <uhd/exception.hpp>
13 #include <uhd/utils/log.hpp>
14 
16 #define _UHD_SAFE_CALL_WARNING(code, what) UHD_LOGGER_ERROR("UHD") << \
17  UHD_THROW_SITE_INFO("Exception caught in safe-call.") + #code + " -> " + what \
18 ;
19 
26 #define UHD_SAFE_CALL(code) \
27  try{code} \
28  catch(const std::exception &e){ \
29  _UHD_SAFE_CALL_WARNING(code, e.what()); \
30  } \
31  catch(...){ \
32  _UHD_SAFE_CALL_WARNING(code, "unknown exception"); \
33  }
34 
35 #endif /* INCLUDED_UHD_UTILS_SAFE_CALL_HPP */