WSL/SLF GitLab Repository

Commit 2d0fc33c authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Printing curl error messages (quite useful to understand what happened!)

parent 795a050b
......@@ -21,6 +21,8 @@
#include <sstream>
#include <iostream>
#include <curl/curl.h>
using namespace std;
namespace mio {
......@@ -232,7 +234,7 @@ void GSNIO::getAllStations()
vecAllMeta.clear();
if (curl_read(sensors_endpoint + "?username=" + userid + "&password=" + passwd, ss) == CURLE_OK) {
if (curl_read(sensors_endpoint + "?username=" + userid + "&password=" + passwd, ss)) {
string name(""), id(""), azi("");
double lat=0., lon=0., alt=0., slope_angle=IOUtils::nodata, slope_azi=IOUtils::nodata;
unsigned int valid = 0;
......@@ -322,7 +324,7 @@ void GSNIO::readData(const Date& dateStart, const Date& dateEnd, std::vector<Met
stringstream ss;
if (curl_read(request, ss) == CURLE_OK) {
if (curl_read(request, ss)) {
vector<size_t> index;
bool olwr_present = false;
......@@ -541,7 +543,7 @@ size_t GSNIO::data_write(void* buf, size_t size, size_t nmemb, void* userp)
return 0;
}
CURLcode GSNIO::curl_read(const std::string& url_query, std::ostream& os)
bool GSNIO::curl_read(const std::string& url_query, std::ostream& os)
{
CURLcode code(CURLE_FAILED_INIT);
CURL* curl = curl_easy_init();
......@@ -561,7 +563,10 @@ CURLcode GSNIO::curl_read(const std::string& url_query, std::ostream& os)
curl_easy_cleanup(curl);
}
return code;
if(code!=CURLE_OK)
std::cout << "[E] " << curl_easy_strerror(code) << "\n";
return (code==CURLE_OK);
}
} //namespace
......@@ -28,8 +28,6 @@
#include <string>
#include <vector>
#include <curl/curl.h>
namespace mio {
/**
......@@ -80,7 +78,7 @@ class GSNIO : public IOInterface {
void parse_streamElement(const std::string& line, const std::vector<size_t>& index,
const bool& olwr_present, std::vector<MeteoData>& vecMeteo, MeteoData& tmpmeteo) const;
static size_t data_write(void* buf, size_t size, size_t nmemb, void* userp);
CURLcode curl_read(const std::string& url, std::ostream& os);
bool curl_read(const std::string& url, std::ostream& os);
const Config cfg;
std::vector<std::string> vecStationName;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment