USRP Hardware Driver and USRP Manual Version: 4.1.0.1
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#pragma once
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) \
16 UHD_LOGGER_ERROR("UHD") << UHD_THROW_SITE_INFO("Exception caught in safe-call.") \
17 + #code + " -> " + what;
18
25#define UHD_SAFE_CALL(code) \
26 try { \
27 code \
28 } catch (const std::exception& e) { \
29 _UHD_SAFE_CALL_WARNING(code, e.what()); \
30 } catch (...) { \
31 _UHD_SAFE_CALL_WARNING(code, "unknown exception"); \
32 }