Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ WINRT_EXPORT namespace winrt
}

com_ptr<impl::IErrorInfo> 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
Expand Down
17 changes: 17 additions & 0 deletions test/test/suppress_error_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "pch.h"
#include <roerrorapi.h>

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");
}
1 change: 1 addition & 0 deletions test/test/test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@
<ClCompile Include="single_threaded_observable_vector.cpp" />
<ClCompile Include="structs.cpp" />
<ClCompile Include="struct_delegate.cpp" />
<ClCompile Include="suppress_error_info.cpp" />
<ClCompile Include="tearoff.cpp" />
<ClCompile Include="thread_pool.cpp" />
<ClCompile Include="uniform_in_params.cpp" />
Expand Down