From 80e0f9c56e6e92b09c2f7f943f2c0b6b754c48a6 Mon Sep 17 00:00:00 2001 From: OleksandrChaika <99030120+OleksandrChaika@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:04:36 +0100 Subject: [PATCH] Print CURL error message to the log (#51) --- src/Download/Downloader.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Download/Downloader.cpp b/src/Download/Downloader.cpp index 09b0fb5..001d158 100644 --- a/src/Download/Downloader.cpp +++ b/src/Download/Downloader.cpp @@ -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); @@ -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, "");