in include/wil/result_macros.h [2870:2944]
inline HRESULT __stdcall ResultFromCaughtException_WinRt(_Inout_updates_opt_(debugStringChars) PWSTR debugString, _When_(debugString != nullptr, _Pre_satisfies_(debugStringChars > 0)) size_t debugStringChars, _Inout_ bool* isNormalized) WI_NOEXCEPT
{
if (g_pfnResultFromCaughtException)
{
try
{
throw;
}
catch (const ResultException& exception)
{
MaybeGetExceptionString(exception, debugString, debugStringChars);
return exception.GetErrorCode();
}
catch (Platform::Exception^ exception)
{
*isNormalized = true;
// We need to call __abi_translateCurrentException so that the CX runtime will pull the originated error information
// out of the exception object and place it back into thread-local storage.
__abi_translateCurrentException(false);
MaybeGetExceptionString(exception, debugString, debugStringChars);
return exception->HResult;
}
catch (const std::bad_alloc& exception)
{
MaybeGetExceptionString(exception, debugString, debugStringChars);
return E_OUTOFMEMORY;
}
catch (...)
{
auto hr = RecognizeCaughtExceptionFromCallback(debugString, debugStringChars);
if (FAILED(hr))
{
return hr;
}
}
}
else
{
try
{
throw;
}
catch (const ResultException& exception)
{
MaybeGetExceptionString(exception, debugString, debugStringChars);
return exception.GetErrorCode();
}
catch (Platform::Exception^ exception)
{
*isNormalized = true;
// We need to call __abi_translateCurrentException so that the CX runtime will pull the originated error information
// out of the exception object and place it back into thread-local storage.
__abi_translateCurrentException(false);
MaybeGetExceptionString(exception, debugString, debugStringChars);
return exception->HResult;
}
catch (const std::bad_alloc& exception)
{
MaybeGetExceptionString(exception, debugString, debugStringChars);
return E_OUTOFMEMORY;
}
catch (std::exception& exception)
{
MaybeGetExceptionString(exception, debugString, debugStringChars);
return HRESULT_FROM_WIN32(ERROR_UNHANDLED_EXCEPTION);
}
catch (...)
{
// Fall through to returning 'S_OK' below
}
}
// Tell the caller that we were unable to map the exception by succeeding...
return S_OK;
}