Make ort errors appear in winml exceptions (#3316)

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
This commit is contained in:
Sheil Kumar 2020-03-25 12:20:40 -07:00 committed by GitHub
parent 4db01309cb
commit 51e95ea946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -46,8 +46,9 @@ inline HRESULT OrtErrorCodeToHRESULT(OrtErrorCode status) noexcept {
auto error_message = ort_api->GetErrorMessage(_status); \
HRESULT hresult = OrtErrorCodeToHRESULT(error_code); \
telemetry_helper.LogRuntimeError(hresult, std::string(error_message), __FILE__, __FUNCTION__, __LINE__); \
RETURN_HR_MSG(hresult, \
error_message); \
auto message = WinML::Strings::HStringFromUTF8(error_message); \
RoOriginateError(hresult, reinterpret_cast<HSTRING>(winrt::get_abi(message))); \
return hresult; \
} \
} while (0)
@ -59,7 +60,7 @@ inline HRESULT OrtErrorCodeToHRESULT(OrtErrorCode status) noexcept {
auto error_message = ort_api->GetErrorMessage(_status); \
HRESULT hresult = OrtErrorCodeToHRESULT(error_code); \
telemetry_helper.LogRuntimeError(hresult, std::string(error_message), __FILE__, __FUNCTION__, __LINE__); \
winrt::hstring errorMessage(WinML::Strings::HStringFromUTF8(error_message)); \
throw winrt::hresult_error(hresult, errorMessage); \
auto message = WinML::Strings::HStringFromUTF8(error_message); \
throw winrt::hresult_error(hresult, message); \
} \
} while (0)

View file

@ -44,7 +44,7 @@
{ \
auto _result = hr; \
telemetry_helper.LogRuntimeError(_result, "", __FILE__, __FUNCTION__, __LINE__); \
throw winrt::hresult_error(_result); \
throw winrt::hresult_error(_result, winrt::hresult_error::from_abi); \
}
#define WINML_THROW_IF_FAILED(hr) \
@ -52,7 +52,7 @@
HRESULT _hr = hr; \
if (FAILED(_hr)) { \
telemetry_helper.LogRuntimeError(_hr, "", __FILE__, __FUNCTION__, __LINE__); \
throw winrt::hresult_error(_hr); \
throw winrt::hresult_error(_hr, winrt::hresult_error::from_abi); \
} \
} while (0)