KEMBAR78
Convert cpprestsdk to WIL exception for better handling by JohnMcPMS · Pull Request #5188 · microsoft/winget-cli · GitHub
Skip to content

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Feb 6, 2025

Change

To better expose the underlying result code, convert the http_exception to a ResultException so that the HRESULT can be properly extracted.

Validation

Using the PowerShell module and interfering with my connection, I was able to see that the connect result's extended error was originally 8007023E, but changed to the appropriate 80072EE2 with the change.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner February 6, 2025 21:41
yao-msft
yao-msft previously approved these changes Feb 6, 2025
return response.extract_json().get();
}

[[noreturn]] void HttpClientHelper::RethrowAsWilException(web::http::http_exception& exception)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be "const &" ?


return ValidateAndExtractResponse(httpResponse);
}
catch (web::http::http_exception& exception)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the 2 catches here and below could be const too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting const on the catch is like putting const on a by-value parameter. It is only there to stop you from changing something you have decided you don't want to change accidentally. I will leave this one.

@JohnMcPMS JohnMcPMS merged commit c32d376 into microsoft:master Feb 10, 2025
9 checks passed
@JohnMcPMS JohnMcPMS deleted the rest-exc branch February 10, 2025 22:07
@JohnMcPMS JohnMcPMS restored the rest-exc branch February 10, 2025 22:07
@JohnMcPMS JohnMcPMS deleted the rest-exc branch February 10, 2025 22:07
JohnMcPMS added a commit to JohnMcPMS/winget-cli that referenced this pull request Feb 10, 2025
## Change
To better expose the underlying result code, convert the
`http_exception` to a `ResultException` so that the HRESULT can be
properly extracted.
JohnMcPMS added a commit that referenced this pull request Feb 11, 2025
## Change
To better expose the underlying result code, convert the
`http_exception` to a `ResultException` so that the HRESULT can be
properly extracted.

CP #5188
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