Improve Errorhandling
This commit is contained in:
+19
-3
@@ -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)
|
||||||
@@ -224,7 +228,7 @@ std::string HttpClientImpl::PerformOperation(const HttpRequest& request) const
|
|||||||
std::stringstream err;
|
std::stringstream err;
|
||||||
err << "Client Error (" << code << ") encountered while retrieving " << url << "\n";
|
err << "Client Error (" << code << ") encountered while retrieving " << url << "\n";
|
||||||
err << "Response: " << buffer << "\n";
|
err << "Response: " << buffer << "\n";
|
||||||
/*
|
/*
|
||||||
if (code == 429)
|
if (code == 429)
|
||||||
{
|
{
|
||||||
// Too Many Requests
|
// Too Many Requests
|
||||||
@@ -232,7 +236,7 @@ std::string HttpClientImpl::PerformOperation(const HttpRequest& request) const
|
|||||||
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
|
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
|
||||||
err << "Retry after " << wait << " seconds\n";
|
err << "Retry after " << wait << " seconds\n";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
error = err.str();
|
error = err.str();
|
||||||
}
|
}
|
||||||
else if (code < 600)
|
else if (code < 600)
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user