Fix cURL error logging for dedicated

Since this file no longer gets build along with the DLL project, but as a static lib instead, the 'DEDICATED' define no longer worked, and therefore this became broken after the CMake port. The 'CURLHandleError' helper function now takes a bool determining whether or not to log the error, and the caller disables it for dedicated (dedicated should only log the error once, this happens from within the caller class).
This commit is contained in:
Kawe Mazidjatari 2023-06-02 00:05:23 +02:00
parent a8f7336d78
commit e891d74656
3 changed files with 7 additions and 4 deletions

View File

@ -407,7 +407,8 @@ bool CPylon::QueryServer(const char* endpoint, const char* request,
}
CURLcode res = CURLSubmitRequest(curl, sList);
if (!CURLHandleError(curl, res, outMessage))
if (!CURLHandleError(curl, res, outMessage,
!IsDedicated(/* Errors are already shown for dedicated! */)))
{
return false;
}

View File

@ -11,7 +11,7 @@ CURL* CURLInitRequest(const char* remote, const char* request, string& outRespon
CURLcode CURLSubmitRequest(CURL* curl, curl_slist*& slist);
CURLINFO CURLRetrieveInfo(CURL* curl);
bool CURLHandleError(CURL* curl, CURLcode res, string& outMessage);
bool CURLHandleError(CURL* curl, const CURLcode res, string& outMessage, const bool logError);
void CURLFormatUrl(string& outUrl, const char* host, const char* api);
#endif // !TIER2_CURLUTILS_H

View File

@ -76,13 +76,15 @@ CURLINFO CURLRetrieveInfo(CURL* curl)
return status;
}
bool CURLHandleError(CURL* curl, CURLcode res, string& outMessage)
bool CURLHandleError(CURL* curl, const CURLcode res, string& outMessage, const bool logError)
{
if (res == CURLE_OK)
return true;
const char* curlError = curl_easy_strerror(res);
Error(eDLL_T::ENGINE, NO_ERROR, "CURL: %s\n", curlError);
if (logError)
Error(eDLL_T::ENGINE, NO_ERROR, "CURL: %s\n", curlError);
outMessage = curlError;
curl_easy_cleanup(curl);