Monado OpenXR Runtime
g_catch_guard.hpp
Go to the documentation of this file.
1// Copyright 2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Catch guards for glue classes.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup aux_util
8 */
9
10#pragma once
11
12#include "xrt/xrt_results.h"
13#include "util/u_logging.h"
14#include <exception>
15
16
17#define G_CATCH_GUARDS_WITH_RETURN(...) \
18 catch (const std::exception &e) \
19 { \
20 U_LOG_E("Uncaught C++ exception: %s", e.what()); \
21 return __VA_ARGS__; \
22 } \
23 catch (...) \
24 { \
25 U_LOG_E("Uncaught unknown C++ exception"); \
26 return __VA_ARGS__; \
27 }
28
29#define G_CATCH_GUARDS_VOID G_CATCH_GUARDS_WITH_RETURN()
30#define G_CATCH_GUARDS G_CATCH_GUARDS_WITH_RETURN(XRT_ERROR_UNCAUGHT_EXCEPTION)
Basic logging functionality.
Internal result type for XRT.