25 #include "ErrorCode.h"
27 #include <olp/core/CoreApi.h>
28 #include "olp/core/client/HttpResponse.h"
29 #include "olp/core/http/HttpStatusCode.h"
72 const char* message =
"Precondition failed") {
127 : error_code_(error_code),
128 message_(std::move(message)),
129 is_retryable_(is_retryable) {
132 static_cast<int>(olp::http::ErrorCode::CANCELLED_ERROR);
146 ApiError(
int http_status_code, std::string message =
"")
147 : error_code_(http::HttpStatusCode::GetErrorCode(http_status_code)),
148 http_status_code_(http_status_code),
149 message_(std::move(message)),
150 is_retryable_(http::HttpStatusCode::IsRetryable(http_status_code)) {}
171 inline const std::string&
GetMessage()
const {
return message_; }
185 std::string message_;
186 bool is_retryable_{
false};
A wrapper around an internal error or HTTP status code.
Definition: ApiError.h:37
static ApiError Cancelled(const char *message="Cancelled")
Creates the ApiError instance with the cancelled error code and description.
Definition: ApiError.h:47
ErrorCode GetErrorCode() const
Gets the error code.
Definition: ApiError.h:157
static ApiError NetworkConnection(const char *message="Offline")
Creates the ApiError instance with the network connection error code and description.
Definition: ApiError.h:59
bool ShouldRetry() const
Checks if the request can be retried for this error.
Definition: ApiError.h:178
const std::string & GetMessage() const
Gets the error message.
Definition: ApiError.h:171
static ApiError InvalidArgument(const char *message="Invalid argument")
Creates the ApiError instance with the invalid argument error code and description.
Definition: ApiError.h:84
int GetHttpStatusCode() const
Gets the HTTP status code.
Definition: ApiError.h:164
static ApiError PreconditionFailed(const char *message="Precondition failed")
Creates the ApiError instance with the precondition failed error code and description.
Definition: ApiError.h:71
ApiError(ErrorCode error_code, std::string message, bool is_retryable=false)
Creates the ApiError instance with the internal error.
Definition: ApiError.h:126
ApiError(int http_status_code, std::string message="")
Creates the ApiError instance with the HTTP status code.
Definition: ApiError.h:146
static ApiError Unknown(const char *message="Unknown")
Creates the ApiError instance with the unknown error code and description.
Definition: ApiError.h:108
static ApiError NotFound(const char *message="Resource not found")
Creates the ApiError instance with the not found error code and description.
Definition: ApiError.h:96
ErrorCode
Represents all possible errors that might happen during a user request.
Definition: ErrorCode.h:29
@ UNKNOWN_ERROR
Internal error that can't be interpreted.
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24