private/RequestHandlerPrivate.cpp
/** ************************************************************************************************
    * @brief        Handle any regular network error.
    *
    * @details      There are two types of error: regular and authentication. Each has its own JSON
    *               format. handleRegularError() and handleAuthenticationError() process the JSON
    *               data differently.
    ***************************************************************************************************/
@brief        Handle any regular network error.
@details      There are two types of error: regular and authentication. Each has its own JSON
format. handleRegularError() and handleAuthenticationError() process the JSON
data differently.
@brief Handle any regular network error . @details There are two types of error : regular and authentication . Each has its own JSON format . handleRegularError () and handleAuthenticationError () process the JSON data differently .
void RequestHandlerPrivate::handleRegularError(RequestHandlerPrivate::ErrorContext context, const QByteArray &errorData)
    {
        Error error(QJsonDocument::fromJson(errorData).object()["error"].toObject());
        qWarning() << "Error in " << ERROR_CONTEXT_STRINGS[static_cast<int>(context)]
                   << ":" << error.getStatus() << "-" << error.getMessage();
        if ("The access token expired" == error.getMessage())
        {
            if (std::chrono::system_clock::now() - m_lastTokenRefresh >= std::chrono::seconds(10))
            {
                refreshToken();
            }
        }
    }
void RequestHandlerPrivate :: handleRegularError ( RequestHandlerPrivate :: ErrorContext context , const QByteArray & errorData ) { Error error ( QJsonDocument :: fromJson ( errorData ) . object ( ) [ " " ] . toObject ( ) ) ; qWarning ( ) << " " << ERROR_CONTEXT_STRINGS [ static_cast < int > ( context ) ] << " " << error . getStatus ( ) << " " << error . getMessage ( ) ; if ( " " == error . getMessage ( ) ) { if ( std :: chrono :: system_clock :: now ( ) - m_lastTokenRefresh >= std :: chrono :: seconds ( 10 ) ) { refreshToken ( ) ; } } }
@brief        Handle any regular network error.
@brief Handle any regular network error .
// If the token has expired try to refresh it. // Do not try more than every 10 seconds.