-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail gracefully when error reporting is suppressed (#1386)
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters