Improve Errorhandling

This commit is contained in:
2025-01-16 14:54:35 +01:00
parent 4ab945772d
commit cc85c0df3a
2 changed files with 87 additions and 70 deletions
+17 -1
View File
@@ -176,10 +176,14 @@ std::string HttpClientImpl::PerformOperation(const HttpRequest& request) const
Logging::Log(Logging::Severity::Debug, debug.str()); Logging::Log(Logging::Severity::Debug, debug.str());
debug.str(""); debug.str("");
CURLcode returnValue;
long code = 0; long code = 0;
curl_easy_perform(curl);
returnValue = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
if (CURLE_OK == returnValue)
{
if (returnType != HttpRequest::ReturnType::Code) if (returnType != HttpRequest::ReturnType::Code)
{ {
if (code < 100) if (code < 100)
@@ -261,6 +265,18 @@ std::string HttpClientImpl::PerformOperation(const HttpRequest& request) const
if (m_debugLogging) if (m_debugLogging)
Logging::Log(Logging::Severity::Debug, debug.str()); Logging::Log(Logging::Severity::Debug, debug.str());
debug.str(""); debug.str("");
}
else if (CURLE_OPERATION_TIMEDOUT == returnValue)
{
std::stringstream err;
err << "Timeout (" << m_timeout << " seconds) encountered while retrieving " << url << "\n";
error = err.str();
debug << "Operation timed out" << std::endl;
if (m_debugLogging)
Logging::Log(Logging::Severity::Debug, debug.str());
debug.str("");
}
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
+1
View File
@@ -5,6 +5,7 @@
LIBRARIES += Logging LIBRARIES += Logging
LIBRARIES += Utilities LIBRARIES += Utilities
CFLAGS += -Wno-deprecated-declarations
CFLAGS += -I$(ROOTPATH)/Libraries/asio/include CFLAGS += -I$(ROOTPATH)/Libraries/asio/include
LFLAGS += -pthread LFLAGS += -pthread