bool DefaultRetryStrategy::shouldRetry()

in sdk/src/client/ClientConfiguration.cc [61:93]


bool DefaultRetryStrategy::shouldRetry(const Error & error, long attemptedRetries) const
{
    if (attemptedRetries >= m_maxRetries)
        return false;

    long responseCode = error.Status();

    // http code
    // accessToken expired, 429 too many requests
    if ((responseCode == 401 && error.Code().compare("AccessTokenInvalid") == 0) ||
        (responseCode == 429) ||
        (responseCode > 499 && responseCode < 599)) {
        return true;
    }
    else {
        switch (responseCode)
        {
        //curl error code
        case (ERROR_CURL_BASE + 7):  //CURLE_COULDNT_CONNECT
        case (ERROR_CURL_BASE + 18): //CURLE_PARTIAL_FILE
        case (ERROR_CURL_BASE + 23): //CURLE_WRITE_ERROR
        case (ERROR_CURL_BASE + 28): //CURLE_OPERATION_TIMEDOUT
        case (ERROR_CURL_BASE + 52): //CURLE_GOT_NOTHING
        case (ERROR_CURL_BASE + 55): //CURLE_SEND_ERROR
        case (ERROR_CURL_BASE + 56): //CURLE_RECV_ERROR
            return true;
        default:
            break;
        };
    }

    return false;
}