Path: blob/master/thirdparty/openxr/src/loader/exception_handling.hpp
9917 views
// Copyright (c) 2019-2025 The Khronos Group Inc.1//2// SPDX-License-Identifier: Apache-2.0 OR MIT3//4// Initial Author: Rylie Pavlik <[email protected]>5//6// Provides protection for C ABI functions if standard library functions may throw.78#pragma once910#ifdef OPENXR_HAVE_COMMON_CONFIG11#include "common_config.h"12#endif // OPENXR_HAVE_COMMON_CONFIG1314#ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING1516#define XRLOADER_ABI_TRY17#define XRLOADER_ABI_CATCH_BAD_ALLOC_OOM18#define XRLOADER_ABI_CATCH_FALLBACK1920#else2122#include <stdexcept>23#define XRLOADER_ABI_TRY try24#define XRLOADER_ABI_CATCH_BAD_ALLOC_OOM \25catch (const std::bad_alloc&) { \26LoaderLogger::LogErrorMessage("", "failed allocating memory"); \27return XR_ERROR_OUT_OF_MEMORY; \28}29#define XRLOADER_ABI_CATCH_FALLBACK \30catch (const std::exception& e) { \31LoaderLogger::LogErrorMessage("", "Unknown failure: " + std::string(e.what())); \32return XR_ERROR_RUNTIME_FAILURE; \33} \34catch (...) { \35LoaderLogger::LogErrorMessage("", "Unknown failure"); \36return XR_ERROR_RUNTIME_FAILURE; \37}3839#endif404142