Skip to content

Commit

Permalink
Print CURL error message to the log (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrChaika authored Nov 9, 2023
1 parent 70df8c1 commit 80e0f9c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Download/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ namespace {
curl_easy_setopt(h, CURLOPT_PROTOCOLS_STR, "https");
CURLcode res = curl_easy_perform(h);

sua::Logger::debug("curl_easy_perform ended with code = '{}'", res);
const auto curl_status_message = fmt::format("curl_easy_perform ended with code = {} ({})", res, curl_easy_strerror(res));

if(res == CURLE_OK) {
sua::Logger::trace(curl_status_message);
} else {
sua::Logger::error(curl_status_message);
}

long http_code = 0;
curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &http_code);
Expand All @@ -174,9 +180,7 @@ namespace {

sua::Logger::debug("CURLINFO_RESPONSE_CODE = {}", http_code);
if(http_code != 200) {
auto e = curl_easy_strerror(res);
sua::Logger::error(e);
return std::make_tuple(sua::TechCode::DownloadFailed, e);
return std::make_tuple(sua::TechCode::DownloadFailed, curl_easy_strerror(res));
}

return std::make_tuple(sua::TechCode::OK, "");
Expand Down

0 comments on commit 80e0f9c

Please sign in to comment.