diff --git a/strings/base_error.h b/strings/base_error.h index 2a6eea281..07d688472 100644 --- a/strings/base_error.h +++ b/strings/base_error.h @@ -313,8 +313,8 @@ WINRT_EXPORT namespace winrt } com_ptr info; - WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void())); - WINRT_VERIFY(info.try_as(m_info)); + WINRT_IMPL_GetErrorInfo(0, info.put_void()); + info.try_as(m_info); } static hresult verify_error(hresult const code) noexcept diff --git a/test/test/suppress_error_info.cpp b/test/test/suppress_error_info.cpp new file mode 100644 index 000000000..f2d25cac1 --- /dev/null +++ b/test/test/suppress_error_info.cpp @@ -0,0 +1,17 @@ +#include "pch.h" +#include + +TEST_CASE("suppress_error_info") +{ + winrt::check_hresult(RoSetErrorReportingFlags(RO_ERROR_REPORTING_SUPPRESSSETERRORINFO)); + + // Since the error information is suppressed, the best we can hope for is that C++/WinRT + // will provide a generic message for the HRESULT. + REQUIRE(winrt::hresult_error(E_FAIL, L"message").message() == L"Unspecified error"); + + winrt::check_hresult(RoSetErrorReportingFlags(RO_ERROR_REPORTING_USESETERRORINFO)); + + // The default behavior has been restored, so C++/WinRT can faithfully provide error + // information as usual. + REQUIRE(winrt::hresult_error(E_FAIL, L"message").message() == L"message"); +} diff --git a/test/test/test.vcxproj b/test/test/test.vcxproj index bb33508a2..b75f2e219 100644 --- a/test/test/test.vcxproj +++ b/test/test/test.vcxproj @@ -418,6 +418,7 @@ +