commit 98b899ac3c5e58b1c090cb6c7d7a881646bc7cc1
parent 08b71b5051285bed74a1470845e5ec426400302f
Author: cfillion <cfillion@users.noreply.github.com>
Date: Thu, 11 Aug 2016 00:02:00 -0400
download: enhance reporting of curl errors
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/download.cpp b/src/download.cpp
@@ -17,10 +17,12 @@
#include "download.hpp"
+#include <boost/format.hpp>
#include <curl/curl.h>
#include <reaper_plugin_functions.h>
+using boost::format;
using namespace std;
Download::Queue Download::s_finished;
@@ -135,20 +137,24 @@ DWORD WINAPI Download::Worker(void *ptr)
headers = curl_slist_append(headers, "Cache-Control: no-cache");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- const CURLcode res = curl_easy_perform(curl);
+ char errbuf[CURL_ERROR_SIZE];
+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
const auto cleanup = [=] {
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
};
+ const CURLcode res = curl_easy_perform(curl);
+
if(download->isAborted()) {
download->finish(Aborted, "aborted by user");
cleanup();
return 1;
}
else if(res != CURLE_OK) {
- download->finish(Failure, curl_easy_strerror(res));
+ const auto err = format("%s (%d): %s") % curl_easy_strerror(res) % res % errbuf;
+ download->finish(Failure, err.str());
cleanup();
return 1;
}