USRP Hardware Driver and USRP Manual  Version: 3.15.0.HEAD-0-g6563c537
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) \
17  UHD_LOGGER_ERROR("UHD") << UHD_THROW_SITE_INFO("Exception caught in safe-call.") \
18  + #code + " -> " + what;
19 
26 #define UHD_SAFE_CALL(code) \
27  try { \
28  code \
29  } catch (const std::exception& e) { \
30  _UHD_SAFE_CALL_WARNING(code, e.what()); \
31  } catch (...) { \
32  _UHD_SAFE_CALL_WARNING(code, "unknown exception"); \
33  }
34 
35 #endif /* INCLUDED_UHD_UTILS_SAFE_CALL_HPP */