From 46f64de7ee5a69eeaa12dfc8a45ad7bff1fad492 Mon Sep 17 00:00:00 2001 From: David Machaj <46852402+dmachaj@users.noreply.github.com.> Date: Tue, 29 Oct 2024 14:24:15 -0700 Subject: [PATCH] Move check_cast_result to impl namespace. Throw an hresult_error directly taking ownership of error info instead of re-originating --- strings/base_error.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/strings/base_error.h b/strings/base_error.h index a3fe77208..8a3a3a088 100644 --- a/strings/base_error.h +++ b/strings/base_error.h @@ -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 WINRT_IMPL_NOINLINE void check_cast_result(T* from WINRT_IMPL_SOURCE_LOCATION_ARGS) { @@ -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