Skip to content

Fix error message loss in IAsyncOperation by replacing std::runtime_error with winrt::hresult_error#16192

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3314246425
Draft

Fix error message loss in IAsyncOperation by replacing std::runtime_error with winrt::hresult_error#16192
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-3314246425

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

GetJavaScriptFromServerAsync was updated to return winrt::Windows::Foundation::IAsyncOperation<IBuffer>, but error paths still threw std::runtime_error. C++/WinRT converts non-WinRT exceptions to a generic HRESULT when propagating failures through IAsyncOperation::get(), silently dropping the detailed packager/HTTP error text that callers rely on for diagnostics.

What

vnext/Shared/DevSupportManager.cpp / DevSupportManager.h

  • Converted GetJavaScriptFromServerAsync return type from std::future<std::pair<std::string, bool>> to IAsyncOperation<IBuffer>
  • Converted PollForLiveReload return type from std::future<HttpStatusCode> to IAsyncOperation<HttpStatusCode>
  • Replaced throw std::runtime_error(error) in HRESULT failure path with throw winrt::hresult_error(hr, winrt::to_hstring(error)) — preserves both the original HRESULT code and message
  • Replaced throw std::runtime_error(error) in HTTP error path with throw winrt::hresult_error(E_FAIL, winrt::to_hstring(error))
  • Removed the catch block that was re-throwing winrt::hresult_error as std::runtime_error, which downgraded the error
  • Updated GetJavaScriptFromServer to unpack the IBuffer result and catch winrt::hresult_error for error reporting
  • Removed #include <future> (no longer used)

Before (error text lost at .get()):

throw std::runtime_error(error); // C++/WinRT maps this to a generic HRESULT, dropping `error`

After (error text preserved):

throw winrt::hresult_error(hr, winrt::to_hstring(error)); // HRESULT + message both survive .get()

Screenshots

N/A

Testing

No new tests added; this is a targeted fix to error-propagation behavior in the WinRT async layer.

Changelog

Should this change be included in the release notes: no

Copilot AI changed the title [WIP] Fix code based on review comment 3314246425 Fix error message loss in IAsyncOperation by replacing std::runtime_error with winrt::hresult_error May 28, 2026
Copilot AI requested a review from JunielKatarn May 28, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants