diff --git a/strings/base_error.h b/strings/base_error.h index c2db6d1ba..45ed39cd3 100644 --- a/strings/base_error.h +++ b/strings/base_error.h @@ -576,12 +576,13 @@ WINRT_EXPORT namespace winrt throw_hresult(impl::hresult_from_win32(WINRT_IMPL_GetLastError())); } - inline void check_hresult(hresult const result) + inline hresult check_hresult(hresult const result) { if (result < 0) { throw_hresult(result); } + return result; } template diff --git a/strings/base_meta.h b/strings/base_meta.h index d2b386442..9c18a84f0 100644 --- a/strings/base_meta.h +++ b/strings/base_meta.h @@ -1,7 +1,7 @@ WINRT_EXPORT namespace winrt { - void check_hresult(hresult const result); + hresult check_hresult(hresult const result); hresult to_hresult() noexcept; template diff --git a/test/old_tests/UnitTests/hresult_error.cpp b/test/old_tests/UnitTests/hresult_error.cpp index 206e06ef5..b9db219f4 100644 --- a/test/old_tests/UnitTests/hresult_error.cpp +++ b/test/old_tests/UnitTests/hresult_error.cpp @@ -10,7 +10,7 @@ TEST_CASE("hresult,S_OK") { // This won't throw - check_hresult(S_OK); + REQUIRE(check_hresult(S_OK) == S_OK); } TEST_CASE("hresult,S_FALSE") @@ -18,7 +18,7 @@ TEST_CASE("hresult,S_FALSE") // This won't throw (unless you define WINRT_STRICT_HRESULT) #ifndef WINRT_STRICT_HRESULT - check_hresult(S_FALSE); + REQUIRE(check_hresult(S_FALSE) == S_FALSE); #else try {