Skip to content

Commit

Permalink
Move check_cast_result to impl namespace. Throw an hresult_error dire…
Browse files Browse the repository at this point in the history
…ctly taking ownership of error info instead of re-originating
  • Loading branch information
dmachaj committed Oct 29, 2024
1 parent a43e3ac commit 903190b
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,24 @@ WINRT_EXPORT namespace winrt
return pointer;
}

[[noreturn]] inline void terminate() noexcept
{
WINRT_IMPL_RoFailFastWithErrorContext(to_hresult());
abort();
}
}

namespace winrt::impl
{
inline hresult check_hresult_allow_bounds(hresult const result WINRT_IMPL_SOURCE_LOCATION_ARGS)
{
if (result != impl::error_out_of_bounds && result != impl::error_fail && result != impl::error_file_not_found)
{
check_hresult(result WINRT_IMPL_SOURCE_LOCATION_FORWARD);
}
return result;
}

template <typename T>
WINRT_IMPL_NOINLINE void check_cast_result(T* from WINRT_IMPL_SOURCE_LOCATION_ARGS)
{
Expand All @@ -545,29 +563,11 @@ WINRT_EXPORT namespace winrt
impl::bstr_handle capabilitySid;
if (restrictedError->GetErrorDetails(description.put(), &code, restrictedDescription.put(), capabilitySid.put()) == 0)
{
check_hresult(code WINRT_IMPL_SOURCE_LOCATION_FORWARD);
throw hresult_error(code, take_ownership_from_abi WINRT_IMPL_SOURCE_LOCATION_FORWARD);
}
}
}
}

[[noreturn]] inline void terminate() noexcept
{
WINRT_IMPL_RoFailFastWithErrorContext(to_hresult());
abort();
}
}

namespace winrt::impl
{
inline hresult check_hresult_allow_bounds(hresult const result WINRT_IMPL_SOURCE_LOCATION_ARGS)
{
if (result != impl::error_out_of_bounds && result != impl::error_fail && result != impl::error_file_not_found)
{
check_hresult(result WINRT_IMPL_SOURCE_LOCATION_FORWARD);
}
return result;
}
}

#undef WINRT_IMPL_RETURNADDRESS

0 comments on commit 903190b

Please sign in to comment.