copy constructor for RequestFailedException (#2291)
* copy constructor for RequestFailedException * Apply suggestions from code review Co-authored-by: Rick Winter <rick.winter@microsoft.com> Co-authored-by: Victor Vazquez <victor.vazquez@microsoft.com> Co-authored-by: Rick Winter <rick.winter@microsoft.com>
This commit is contained in:
parent
ff126f1eb7
commit
9261e9ddae
@ -92,5 +92,28 @@ namespace Azure { namespace Core {
|
||||
explicit RequestFailedException(
|
||||
const std::string& message,
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse);
|
||||
|
||||
/**
|
||||
* @brief Constructs a new `RequestFailedException` by copying from an existing one.
|
||||
* @note Copies the #Azure::Core::Http::RawResponse into the new `RequestFailedException`.
|
||||
*
|
||||
* @param other The `RequestFailedException` to be copied.
|
||||
*/
|
||||
RequestFailedException(const RequestFailedException& other)
|
||||
: std::runtime_error(other.Message), StatusCode(other.StatusCode),
|
||||
ReasonPhrase(other.ReasonPhrase), ClientRequestId(other.ClientRequestId),
|
||||
RequestId(other.RequestId), ErrorCode(other.ErrorCode), Message(other.Message),
|
||||
RawResponse(std::make_unique<Azure::Core::Http::RawResponse>(*other.RawResponse))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructs a new `RequestFailedException`.
|
||||
* @note Transfers ownership of the #Azure::Core::Http::RawResponse to the new
|
||||
* `RequestFailedException`.
|
||||
*
|
||||
* @param other An rvalue reference for moving the `RequestFailedException`.
|
||||
*/
|
||||
RequestFailedException(RequestFailedException&& other) = default;
|
||||
};
|
||||
}} // namespace Azure::Core
|
||||
|
||||
@ -76,10 +76,19 @@ namespace Azure { namespace Core { namespace Http {
|
||||
response.m_statusCode,
|
||||
response.m_reasonPhrase)
|
||||
{
|
||||
AZURE_ASSERT(m_bodyStream == nullptr);
|
||||
// Copy body
|
||||
m_body = response.GetBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructs a new `RawResponse`.
|
||||
* @note Transfers ownership of the `RawResponse` to the new `RawResponse`.
|
||||
*
|
||||
* @param response An rvalue reference for moving the raw response.
|
||||
*/
|
||||
RawResponse(RawResponse&& response) = default;
|
||||
|
||||
// ===== Methods used to build HTTP response =====
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user