USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
safe_call.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2011 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_UTILS_SAFE_CALL_HPP
8 #define INCLUDED_UHD_UTILS_SAFE_CALL_HPP
9 
10 #include <uhd/config.hpp>
11 #include <uhd/exception.hpp>
12 #include <uhd/utils/log.hpp>
13 
15 #define _UHD_SAFE_CALL_WARNING(code, what) UHD_LOGGER_ERROR("UHD") << \
16  UHD_THROW_SITE_INFO("Exception caught in safe-call.") + #code + " -> " + what \
17 ;
18 
25 #define UHD_SAFE_CALL(code) \
26  try{code} \
27  catch(const std::exception &e){ \
28  _UHD_SAFE_CALL_WARNING(code, e.what()); \
29  } \
30  catch(...){ \
31  _UHD_SAFE_CALL_WARNING(code, "unknown exception"); \
32  }
33 
34 #endif /* INCLUDED_UHD_UTILS_SAFE_CALL_HPP */