Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jangernert/FeedReader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Long <self@brendanlong.com>2019-02-09 02:03:37 +0300
committerBrendan Long <self@brendanlong.com>2019-02-09 18:59:51 +0300
commit6e68849f7b3c0ca196a65935cc3ae9d48b115581 (patch)
tree4b293f2a8340a2b9d73ffc559fc24d4e438dea23 /plugins
parent88cf9b92db44923f5c9cc33a58fc4597d8581cc7 (diff)
Improve error messages when adding a feed fails
Previous a lot of errors just said "Failed to add the feed", which was confusing for users. - Always show the URL we attempted to download in the error message - Add a special message for network errors - Show the HTTP status code if we got an error - Explain more specifically what happened when parsing fails
Diffstat (limited to 'plugins')
-rw-r--r--plugins/backend/decsync/decsyncUtils.vala38
-rw-r--r--plugins/backend/local/localUtils.vala37
2 files changed, 48 insertions, 27 deletions
diff --git a/plugins/backend/decsync/decsyncUtils.vala b/plugins/backend/decsync/decsyncUtils.vala
index 93534b83..0ee6cf39 100644
--- a/plugins/backend/decsync/decsyncUtils.vala
+++ b/plugins/backend/decsync/decsyncUtils.vala
@@ -43,23 +43,34 @@ public void setDecsyncDir(string decsyncDir)
Utils.gsettingWriteString(m_settings, "decsync-dir", decsyncDir);
}
-public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Gee.List<string> catIDs, out string errmsg)
+public Feed? downloadFeed(Soup.Session session, string feed_url, string feedID, Gee.List<string> catIDs, out string errmsg)
{
- errmsg = "";
+ var error = new StringBuilder(_("Failed to add feed"));
+ error.append_printf(" %s\n", feed_url);
- // download
- //Logger.debug(@"Requesting: $xmlURL");
- var msg = new Soup.Message("GET", xmlURL);
+ var msg = new Soup.Message("GET", feed_url);
if (msg == null)
{
- errmsg = @"Couldn't parse feed URL: $xmlURL";
+ error.append(_("Failed to parse URL."));
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
+
uint status = session.send_message(msg);
- if(status != 200)
+ if(status < 100 || status >= 400)
{
- errmsg = "Could not download feed";
+ if(status < 100)
+ {
+ error.append(_("Network error connecting to the server."));
+ }
+ else
+ {
+ error.append(_("Got HTTP error code"));
+ error.append_printf(" %u %s", status, Soup.Status.get_phrase(status));
+ }
+
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
@@ -68,14 +79,14 @@ public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Ge
// parse
Rss.Parser parser = new Rss.Parser();
-
try
{
parser.load_from_data(xml, xml.length);
}
catch(Error e)
{
- errmsg = "Could not parse feed";
+ error.append(_("Could not parse feed as RSS or ATOM."));
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
@@ -86,16 +97,15 @@ public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Ge
&& doc.link != "")
url = doc.link;
- var Feed = new Feed(
+ errmsg = "";
+ return new Feed(
feedID,
doc.title,
url,
0,
catIDs,
doc.image_url,
- xmlURL);
-
- return Feed;
+ feed_url);
}
public string? convert(string? text, string? locale)
diff --git a/plugins/backend/local/localUtils.vala b/plugins/backend/local/localUtils.vala
index b5bde240..4f10ba21 100644
--- a/plugins/backend/local/localUtils.vala
+++ b/plugins/backend/local/localUtils.vala
@@ -20,23 +20,34 @@ public localUtils()
}
-public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Gee.List<string> catIDs, out string errmsg)
+public Feed? downloadFeed(Soup.Session session, string feed_url, string feedID, Gee.List<string> catIDs, out string errmsg)
{
- errmsg = "";
+ var error = new StringBuilder(_("Failed to add feed"));
+ error.append_printf(" %s\n", feed_url);
- // download
- //Logger.debug(@"Requesting: $xmlURL");
- var msg = new Soup.Message("GET", xmlURL);
+ var msg = new Soup.Message("GET", feed_url);
if (msg == null)
{
- errmsg = @"Couldn't parse feed URL: $xmlURL";
+ error.append(_("Failed to parse URL."));
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
+
uint status = session.send_message(msg);
- if(status != 200)
+ if(status < 100 || status >= 400)
{
- errmsg = "Could not download feed";
+ if(status < 100)
+ {
+ error.append(_("Network error connecting to the server."));
+ }
+ else
+ {
+ error.append(_("Got HTTP error code"));
+ error.append_printf(" %u %s", status, Soup.Status.get_phrase(status));
+ }
+
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
@@ -51,7 +62,8 @@ public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Ge
}
catch(Error e)
{
- errmsg = "Could not parse feed";
+ error.append(_("Could not parse feed as RSS or ATOM."));
+ errmsg = error.str;
Logger.warning(errmsg);
return null;
}
@@ -62,16 +74,15 @@ public Feed? downloadFeed(Soup.Session session, string xmlURL, string feedID, Ge
&& doc.link != "")
url = doc.link;
- var Feed = new Feed(
+ errmsg = "";
+ return new Feed(
feedID,
doc.title,
url,
0,
catIDs,
doc.image_url,
- xmlURL);
-
- return Feed;
+ feed_url);
}
public string? convert(string? text, string? locale)