diff options
author | 2017-08-12 14:32:02 +0300 | |
---|---|---|
committer | 2017-08-12 14:32:02 +0300 | |
commit | 2619d1f41303700deff15d9781005176aec8ddce (patch) | |
tree | 46bab762d488c502e2274266d82c37270ef799d6 /rss/parser.cpp | |
parent | 91641e3f89dbd29d2a23a6530fc833e687eb7953 (diff) | |
download | newsboat-2619d1f41303700deff15d9781005176aec8ddce.tar.gz newsboat-2619d1f41303700deff15d9781005176aec8ddce.tar.zst newsboat-2619d1f41303700deff15d9781005176aec8ddce.zip |
Show HTTP error code if fetching failed
Diffstat (limited to '')
-rw-r--r-- | rss/parser.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
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); |