diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 21939dc60..415b38a47 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -9,6 +9,7 @@ ### Breaking Changes - Removed the `AzureNoReturnPath()` function from the global namespace, and deprecated the associated macros, such as `AZURE_ASSERT` since they are meant for internal use only. If your code was using the `AZURE_ASSERT` macro, consider using the standard library's `assert` as an alternative. +- Removed the two parameter `RequestFailedException` ctor, it has no use case and wasn't intended for public use. ### Bugs Fixed diff --git a/sdk/core/azure-core/inc/azure/core/exception.hpp b/sdk/core/azure-core/inc/azure/core/exception.hpp index 939382939..52d9ab3dd 100644 --- a/sdk/core/azure-core/inc/azure/core/exception.hpp +++ b/sdk/core/azure-core/inc/azure/core/exception.hpp @@ -77,21 +77,6 @@ namespace Azure { namespace Core { */ explicit RequestFailedException(std::string const& what) : std::runtime_error(what) {} - /** - * @brief Constructs a new `%RequestFailedException` object with an HTTP raw response. - * - * @note The HTTP raw response is parsed to populate information expected from all Azure - * Services like the status code, reason phrase and some headers like the request ID. A concrete - * Service exception which derives from this exception uses its constructor to parse the HTTP - * raw response adding the service specific values to the exception. - * - * @param what The explanatory string. - * @param rawResponse The HTTP raw response from the service. - */ - explicit RequestFailedException( - const std::string& what, - std::unique_ptr& rawResponse); - /** * @brief Constructs a new `%RequestFailedException` object with an HTTP raw response. * diff --git a/sdk/core/azure-core/src/exception.cpp b/sdk/core/azure-core/src/exception.cpp index fe6710848..11fdf3a2c 100644 --- a/sdk/core/azure-core/src/exception.cpp +++ b/sdk/core/azure-core/src/exception.cpp @@ -16,9 +16,8 @@ using namespace Azure::Core::Http::_internal; namespace Azure { namespace Core { RequestFailedException::RequestFailedException( - const std::string& what, std::unique_ptr& rawResponse) - : std::runtime_error(what) + : std::runtime_error("Received an HTTP unsuccessful status code.") { const auto& headers = rawResponse->GetHeaders(); @@ -35,12 +34,6 @@ namespace Azure { namespace Core { RequestId = HttpShared::GetHeaderOrEmptyString(headers, HttpShared::MsRequestId); } - RequestFailedException::RequestFailedException( - std::unique_ptr& rawResponse) - : RequestFailedException("Received an HTTP unsuccessful status code.", rawResponse) - { - } - std::string RequestFailedException::GetRawResponseField( std::unique_ptr& rawResponse, std::string fieldName) diff --git a/sdk/core/azure-core/test/ut/exception_test.cpp b/sdk/core/azure-core/test/ut/exception_test.cpp index b74cb60ba..09b6db0bc 100644 --- a/sdk/core/azure-core/test/ut/exception_test.cpp +++ b/sdk/core/azure-core/test/ut/exception_test.cpp @@ -76,30 +76,3 @@ TEST(RequestFailedException, EmptyValues) EXPECT_EQ(exception.ReasonPhrase, std::string()); EXPECT_EQ(exception.what(), std::string("Received an HTTP unsuccessful status code.")); } - -TEST(RequestFailedException, Message) -{ - auto response = std::make_unique( - 1, 1, Azure::Core::Http::HttpStatusCode::ServiceUnavailable, "retry please :"); - static constexpr uint8_t const responseBody[] - = "{\"error\":{ \"code\":\"503\", \"message\":\"JT\"}}"; - static constexpr uint8_t const responseBodyStream[] - = "{\"error\":{ \"code\":\"503\", \"message\":\"JT\"}}"; - - response->SetHeader(HttpShared::ContentType, "application/json"); - response->SetHeader(HttpShared::MsRequestId, "1"); - response->SetHeader(HttpShared::MsClientRequestId, "2"); - response->SetBody(std::vector(responseBody, responseBody + sizeof(responseBody))); - response->SetBodyStream(std::make_unique( - responseBodyStream, sizeof(responseBodyStream) - 1)); - - auto exception = Azure::Core::RequestFailedException("what", response); - - EXPECT_EQ(exception.StatusCode, Azure::Core::Http::HttpStatusCode::ServiceUnavailable); - EXPECT_EQ(exception.Message, "JT"); - EXPECT_EQ(exception.ErrorCode, "503"); - EXPECT_EQ(exception.RequestId, "1"); - EXPECT_EQ(exception.ClientRequestId, "2"); - EXPECT_EQ(exception.ReasonPhrase, "retry please :"); - EXPECT_EQ(exception.what(), std::string("what")); -}