Repository navigation
Preserve RequestFailedException what() when copying - #7484
Open
Joel Town Road (hippi345) wants to merge 1 commit into
Open
Joel Town Road (hippi345) wants to merge 1 commit into
Joel Town Road (hippi345) wants to merge 1 commit into
Conversation
Initialize the copy constructor from other.what() instead of other.Message so copies keep the original explanatory string.
|
Thank you for your contribution Joel Town Road (@hippi345)! We will review the pull request and get back to you soon. |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 8 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix addresses the reported defect with regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes #7272 by preserving RequestFailedException::what() when copying, including inherited behavior in derived exceptions.
Changes:
- Initializes the copied exception’s base from
other.what(). - Adds regression coverage for preserving diagnostics and
Message. - Documents the fix and consumer rebuild requirement.
| File | Description |
|---|---|
| sdk/core/azure-core/test/ut/exception_test.cpp | Tests preservation of what() and Message after copying. |
| sdk/core/azure-core/inc/azure/core/exception.hpp | Corrects the copy constructor’s base initialization. |
| sdk/core/azure-core/CHANGELOG.md | Records the fix and rebuild requirement. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please leverage this checklist as a reminder to address commonly occurring feedback when submitting a pull request to make sure your PR can be reviewed quickly:
See the detailed list in the contributing guide.
Problem
Azure::Core::RequestFailedException's copy constructor initializedstd::runtime_errorfromother.Messageinstead ofother.what(). Those strings are not the same:what()and leavesMessageempty.what()to the HTTP status/reason text and setsMessageto the servicemessagefield (for example"JT").A copy therefore replaced
what()withMessage. Derived types such asAzure::Storage::StorageExceptioninherit this constructor and have the same defect.StorageExceptiondoes not declare its own copy constructor, so no storage-side change was required.Fixes #7272
Change
In
RequestFailedException(const RequestFailedException&), initialize the base withother.what()so a copy preserveswhat()andMessageexactly. Copy/move assignment operators remain= delete. There are no public API changes.Because the copy constructor is inline in an installed header, consumers linking a prebuilt binary must rebuild to pick up the fix.
Testing
Added
RequestFailedException.CopyPreservesWhatAndMessageinsdk/core/azure-core/test/ut/exception_test.cpp. It builds aRequestFailedExceptionfrom aRawResponsewith a JSON error body (message:"JT"), copies it, and assertscopy.what()andcopy.Messageequal the original.Before (unmodified copy constructor) — gtest assertion failure, not a compile error:
After:
Full
azure-core-testbinary: 368 tests ran, 330 passed, remaining skipped/disabled (live transport).ctest -R azure-corefromsdk/core/azure-core/build/test/ut: 373 discovered tests, exception tests passed; the only CTest failures were pre-existing*_NOT_BUILTplaceholders for binaries not built in this targetedazure-core-testcompile.This change was prepared with AI assistance and reviewed by the author.