azure-core
Public Member Functions | Public Attributes | List of all members
Azure::Core::RequestFailedException Class Reference

An error while trying to send a request to Azure service. More...

#include <exception.hpp>

Inheritance diagram for Azure::Core::RequestFailedException:
Azure::Core::Http::TransportException

Public Member Functions

 RequestFailedException (std::string const &what)
 Constructs a new RequestFailedException with a message string. More...
 
 RequestFailedException (std::unique_ptr< Azure::Core::Http::RawResponse > &rawResponse)
 Constructs a new RequestFailedException object with an HTTP raw response. More...
 
 RequestFailedException (const RequestFailedException &other)
 Constructs a new RequestFailedException by copying from an existing one. More...
 
 RequestFailedException (RequestFailedException &&other)=default
 Constructs a new RequestFailedException by moving in an existing one. More...
 
RequestFailedExceptionoperator= (const RequestFailedException &)=delete
 An instance of RequestFailedException class cannot be assigned. More...
 
RequestFailedExceptionoperator= (RequestFailedException &&)=delete
 An instance of RequestFailedException class cannot be moved into another instance after creation. More...
 
 ~RequestFailedException ()=default
 Destructs RequestFailedException. More...
 

Public Attributes

std::unique_ptr< Azure::Core::Http::RawResponseRawResponse
 The entire HTTP raw response. More...
 
Azure::Core::Http::HttpStatusCode StatusCode = Azure::Core::Http::HttpStatusCode::None
 The HTTP response code. More...
 
std::string ReasonPhrase
 The HTTP reason phrase from the response. More...
 
std::string ClientRequestId
 The client request header (x-ms-client-request-id) from the HTTP response. More...
 
std::string RequestId
 The request ID header (x-ms-request-id) from the HTTP response. More...
 
std::string ErrorCode
 The error code from service returned in the HTTP response. More...
 
std::string Message
 The error message from the service returned in the HTTP response. More...
 

Detailed Description

A RequestFailedException is sometimes generated as a result of an HTTP response returned from the service, and is sometimes generated for other reasons. The contents of the RequestFailedException depend on whether the exception was thrown as a result of an HTTP response error or other reasons.

To determine which form of RequestFailedException has occurred, a client can check the RequestFailedException::RawResponse field - if that value is null, then the request failed for some reason other than an HTTP response, the reason can be determined by calling RequestFailedException::what().

If the request has failed due to an HTTP response code, the client can inspect other fields in the exception to determine the actual failure returned by the service.

Most Azure services follow the Azure standards for error condition responses and return an error object containing two properties, code and message. These properties are used to populate the RequestFailedException::ErrorCode and RequestFailedException::Message fields

{
std::cout << "Request Failed Exception happened:" << std::endl << e.what() << std::endl;
if (e.RawResponse)
{
std::cout << "Error Code: " << e.ErrorCode << std::endl;
std::cout << "Error Message: " << e.Message << std::endl;
}
return 0;
}

Constructor & Destructor Documentation

◆ RequestFailedException() [1/4]

Azure::Core::RequestFailedException::RequestFailedException ( std::string const &  what)
explicit
Note
An Exception without an HTTP raw response represents an exception that is not associated with an HTTP response. Typically this is an error which occurred before the response was received from the service.
Parameters
whatThe explanatory string.

◆ RequestFailedException() [2/4]

Azure::Core::RequestFailedException::RequestFailedException ( std::unique_ptr< Azure::Core::Http::RawResponse > &  rawResponse)
explicit
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.
Parameters
rawResponseThe HTTP raw response from the service.

◆ RequestFailedException() [3/4]

Azure::Core::RequestFailedException::RequestFailedException ( const RequestFailedException other)
inline
Note
Copies the Azure::Core::Http::RawResponse into the new RequestFailedException.
Parameters
otherThe RequestFailedException to be copied.

◆ RequestFailedException() [4/4]

Azure::Core::RequestFailedException::RequestFailedException ( RequestFailedException &&  other)
default
Parameters
otherThe RequestFailedException to move in.

◆ ~RequestFailedException()

Azure::Core::RequestFailedException::~RequestFailedException ( )
default

Member Function Documentation

◆ operator=() [1/2]

RequestFailedException& Azure::Core::RequestFailedException::operator= ( const RequestFailedException )
delete

◆ operator=() [2/2]

RequestFailedException& Azure::Core::RequestFailedException::operator= ( RequestFailedException &&  )
delete

Member Data Documentation

◆ ClientRequestId

std::string Azure::Core::RequestFailedException::ClientRequestId

◆ ErrorCode

std::string Azure::Core::RequestFailedException::ErrorCode

For more information, see Azure standards for error condition responses, specifically the handling of the "code" property.

Note that the contents of the ErrorCode is service dependent.

◆ Message

std::string Azure::Core::RequestFailedException::Message

For more information, see Azure standards for error condition responses, specifically the handling of the "message" property.

Note
This string is purely for informational or diagnostic purposes, and should't be relied on at runtime.

◆ RawResponse

std::unique_ptr<Azure::Core::Http::RawResponse> Azure::Core::RequestFailedException::RawResponse

◆ ReasonPhrase

std::string Azure::Core::RequestFailedException::ReasonPhrase

◆ RequestId

std::string Azure::Core::RequestFailedException::RequestId

◆ StatusCode

Azure::Core::Http::HttpStatusCode Azure::Core::RequestFailedException::StatusCode = Azure::Core::Http::HttpStatusCode::None

The documentation for this class was generated from the following files:
Azure::Core::RequestFailedException::Message
std::string Message
The error message from the service returned in the HTTP response.
Definition: exception.hpp:112
Azure::Core::RequestFailedException::ErrorCode
std::string ErrorCode
The error code from service returned in the HTTP response.
Definition: exception.hpp:99
Azure::Core::RequestFailedException
An error while trying to send a request to Azure service.
Definition: exception.hpp:57
Azure::Core::RequestFailedException::RawResponse
std::unique_ptr< Azure::Core::Http::RawResponse > RawResponse
The entire HTTP raw response.
Definition: exception.hpp:63