From 2619d1f41303700deff15d9781005176aec8ddce Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Sat, 12 Aug 2017 14:32:02 +0300 Subject: Show HTTP error code if fetching failed --- rss/parser.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'rss/parser.cpp') diff --git a/rss/parser.cpp b/rss/parser.cpp index 991c147c..eb928142 100644 --- a/rss/parser.cpp +++ b/rss/parser.cpp @@ -158,11 +158,7 @@ feed parser::parse_url(const std::string& url, time_t lastmodified, const std::s LOG(level::DEBUG, "rsspp::parser::parse_url: ret = %d", ret); long status; - curl_easy_getinfo(easyhandle, CURLINFO_HTTP_CONNECTCODE, &status); - - if (status >= 400) { - LOG(level::USERERROR, _("Error: trying to download feed `%s' returned HTTP status code %ld."), url, status); - } + CURLcode infoOk = curl_easy_getinfo(easyhandle, CURLINFO_RESPONSE_CODE, &status); curl_easy_reset(easyhandle); @@ -171,7 +167,13 @@ feed parser::parse_url(const std::string& url, time_t lastmodified, const std::s if (ret != 0) { LOG(level::ERROR, "rsspp::parser::parse_url: curl_easy_perform returned err %d: %s", ret, curl_easy_strerror(ret)); - throw exception(curl_easy_strerror(ret)); + std::string msg; + if (ret == CURLE_HTTP_RETURNED_ERROR && infoOk == CURLE_OK) { + msg = strprintf::fmt("%s %li", curl_easy_strerror(ret), status); + } else { + msg = curl_easy_strerror(ret); + } + throw exception(msg); } LOG(level::INFO, "parser::parse_url: retrieved data for %s: %s", url, buf); -- cgit v1.2.3