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
3 changes: 2 additions & 1 deletion strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
Expand Down
2 changes: 1 addition & 1 deletion strings/base_meta.h
Original file line number Diff line number Diff line change
@@ -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 <typename D, typename I>
Expand Down
4 changes: 2 additions & 2 deletions test/old_tests/UnitTests/hresult_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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")
{
// 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
{
Expand Down