Removing the two param RFE ctor, there should be no callers (#3215)

* Removing the two param RFE ctor, there should be no callers

* Remove the two param RFE ctor from the source file.

* Fix-up unit test and add a changelog entry.

* Remove test that uses the removed ctor.
This commit is contained in:
Ahson Khan 2022-02-03 19:00:25 -08:00 committed by GitHub
parent 40a3e34068
commit 9c79a0725d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 50 deletions

View File

@ -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

View File

@ -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<Azure::Core::Http::RawResponse>& rawResponse);
/**
* @brief Constructs a new `%RequestFailedException` object with an HTTP raw response.
*

View File

@ -16,9 +16,8 @@ using namespace Azure::Core::Http::_internal;
namespace Azure { namespace Core {
RequestFailedException::RequestFailedException(
const std::string& what,
std::unique_ptr<Azure::Core::Http::RawResponse>& 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<Azure::Core::Http::RawResponse>& rawResponse)
: RequestFailedException("Received an HTTP unsuccessful status code.", rawResponse)
{
}
std::string RequestFailedException::GetRawResponseField(
std::unique_ptr<Azure::Core::Http::RawResponse>& rawResponse,
std::string fieldName)

View File

@ -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<Azure::Core::Http::RawResponse>(
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<uint8_t>(responseBody, responseBody + sizeof(responseBody)));
response->SetBodyStream(std::make_unique<Azure::Core::IO::MemoryBodyStream>(
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"));
}