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") {
151 : error_code_(error_code),
152 message_(std::move(message)),
153 is_retryable_(is_retryable) {
156 static_cast<int>(olp::http::ErrorCode::CANCELLED_ERROR);
170 ApiError(
int http_status_code, std::string message =
"")
171 : error_code_(http::HttpStatusCode::GetErrorCode(http_status_code)),
172 http_status_code_(http_status_code),
173 message_(std::move(message)),
174 is_retryable_(http::HttpStatusCode::IsRetryable(http_status_code)) {}
195 inline const std::string&
GetMessage()
const {
return message_; }
209 std::string message_;
210 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:181
static ApiError Offline(const char *description="Offline")
Creates the ApiError instance with the offline error code and description.
Definition: ApiError.h:120
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:202
const std::string & GetMessage() const
Gets the error message.
Definition: ApiError.h:195
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:188
static ApiError PreconditionFailed(const char *message="Precondition failed")
Creates the ApiError instance with the precondition failed error code and description.
Definition: ApiError.h:71
static ApiError CacheIO(const char *description="Cache IO")
Creates the ApiError instance with the cache IO error code and description.
Definition: ApiError.h:108
ApiError(ErrorCode error_code, std::string message, bool is_retryable=false)
Creates the ApiError instance with the internal error.
Definition: ApiError.h:150
ApiError(int http_status_code, std::string message="")
Creates the ApiError instance with the HTTP status code.
Definition: ApiError.h:170
static ApiError Unknown(const char *message="Unknown")
Creates the ApiError instance with the unknown error code and description.
Definition: ApiError.h:132
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