olp-cpp-sdk  1.21.0
Public Member Functions | Static Public Member Functions | List of all members
olp::client::ApiError Class Reference

A wrapper around an internal error or HTTP status code. More...

#include <ApiError.h>

Public Member Functions

 ApiError (ErrorCode error_code, std::string message, bool is_retryable=false)
 Creates the ApiError instance with the internal error. More...
 
 ApiError (int http_status_code, std::string message="")
 Creates the ApiError instance with the HTTP status code. More...
 
ErrorCode GetErrorCode () const
 Gets the error code. More...
 
int GetHttpStatusCode () const
 Gets the HTTP status code. More...
 
const std::string & GetMessage () const
 Gets the error message. More...
 
bool ShouldRetry () const
 Checks if the request can be retried for this error. More...
 

Static Public Member Functions

static ApiError Cancelled (const char *message="Cancelled")
 Creates the ApiError instance with the cancelled error code and description. More...
 
static ApiError NetworkConnection (const char *message="Offline")
 Creates the ApiError instance with the network connection error code and description. More...
 
static ApiError PreconditionFailed (const char *message="Precondition failed")
 Creates the ApiError instance with the precondition failed error code and description. More...
 
static ApiError InvalidArgument (const char *message="Invalid argument")
 Creates the ApiError instance with the invalid argument error code and description. More...
 
static ApiError NotFound (const char *message="Resource not found")
 Creates the ApiError instance with the not found error code and description. More...
 
static ApiError CacheIO (const char *description="Cache IO")
 Creates the ApiError instance with the cache IO error code and description. More...
 
static ApiError Unknown (const char *message="Unknown")
 Creates the ApiError instance with the unknown error code and description. More...
 

Detailed Description

A wrapper around an internal error or HTTP status code.

Constructor & Destructor Documentation

◆ ApiError() [1/2]

olp::client::ApiError::ApiError ( ErrorCode  error_code,
std::string  message,
bool  is_retryable = false 
)
inline

Creates the ApiError instance with the internal error.

Represents the internal error that is not related to any HTTP status returned during the request. You can call this constructor using the error code and error message.

Parameters
error_codeThe internal error code.
messageThe text message of the error.
is_retryableIndicates if the error is permanent or temporary and if the user can retry the operation.

◆ ApiError() [2/2]

olp::client::ApiError::ApiError ( int  http_status_code,
std::string  message = "" 
)
inline

Creates the ApiError instance with the HTTP status code.

Represents the server status. Evaluates the HTTP status code and sets the error_code_ and is_retriable_ flag parameters. You can call this constructor using the HTTP status code and error text message.

Parameters
http_status_codeThe HTTP status code returned by the server.
messageThe text message of the error.

Member Function Documentation

◆ CacheIO()

static ApiError olp::client::ApiError::CacheIO ( const char *  description = "Cache IO")
inlinestatic

Creates the ApiError instance with the cache IO error code and description.

Parameters
descriptionThe optional description.
Returns
The ApiError instance.

◆ Cancelled()

static ApiError olp::client::ApiError::Cancelled ( const char *  message = "Cancelled")
inlinestatic

Creates the ApiError instance with the cancelled error code and description.

Parameters
messageThe optional description.
Returns
The ApiError instance.

◆ GetErrorCode()

ErrorCode olp::client::ApiError::GetErrorCode ( ) const
inline

Gets the error code.

Returns
The code associated with the error.

◆ GetHttpStatusCode()

int olp::client::ApiError::GetHttpStatusCode ( ) const
inline

Gets the HTTP status code.

Returns
The HTTP status code.

◆ GetMessage()

const std::string& olp::client::ApiError::GetMessage ( ) const
inline

Gets the error message.

Returns
The error message associated with the error.

◆ InvalidArgument()

static ApiError olp::client::ApiError::InvalidArgument ( const char *  message = "Invalid argument")
inlinestatic

Creates the ApiError instance with the invalid argument error code and description.

Parameters
messageThe optional description.
Returns
The ApiError instance.

◆ NetworkConnection()

static ApiError olp::client::ApiError::NetworkConnection ( const char *  message = "Offline")
inlinestatic

Creates the ApiError instance with the network connection error code and description.

Parameters
messageThe optional description.
Returns
The ApiError instance.

◆ NotFound()

static ApiError olp::client::ApiError::NotFound ( const char *  message = "Resource not found")
inlinestatic

Creates the ApiError instance with the not found error code and description.

Parameters
descriptionThe optional description.
Returns
The ApiError instance.

◆ PreconditionFailed()

static ApiError olp::client::ApiError::PreconditionFailed ( const char *  message = "Precondition failed")
inlinestatic

Creates the ApiError instance with the precondition failed error code and description.

Parameters
messageThe optional description.
Returns
The ApiError instance.

◆ ShouldRetry()

bool olp::client::ApiError::ShouldRetry ( ) const
inline

Checks if the request can be retried for this error.

Returns
True if the request can be retried for this error; false otherwise.

◆ Unknown()

static ApiError olp::client::ApiError::Unknown ( const char *  message = "Unknown")
inlinestatic

Creates the ApiError instance with the unknown error code and description.

Parameters
descriptionThe optional description.
Returns
The ApiError instance.

The documentation for this class was generated from the following file: