Fix the error message when a redirect-edit fails.
authorAdam Sampson <ats@offog.org>
Tue, 28 Feb 2017 19:09:02 +0000 (19:09 +0000)
committerAdam Sampson <ats@offog.org>
Tue, 28 Feb 2017 19:09:02 +0000 (19:09 +0000)
This has been broken since 2.15 ("Make it possible to report more than
one error at once."); I'd forgotten that change_feed_url also prints
messages when adding the "errors" code.

NEWS
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index 0223e9652ae72a7bedb43932d9718d239627b098..044c092fd494c20c5595ab358ed728da9103e96f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 - rawdog 2.23
 
+When automatically updating the config file in response to an HTTP
+redirect fails, produce a more sensible error message (including the URL
+of the feed in question).
+
 - rawdog 2.22
 
 When handling an HTTP 301 redirect response, check whether the new
index a5e6bfed485109975aa53f66ff63c323fe868a62..64ae93f13341bc7020c3aca3c97053c92a5a0f27 100644 (file)
@@ -562,8 +562,7 @@ class Feed:
                                errors.append("New URL:     " + location)
                                errors.append("The feed has moved permanently to a new URL.")
                                if config["changeconfig"]:
-                                       rawdog.change_feed_url(self.url, location, config)
-                                       errors.append("The config file has been updated automatically.")
+                                       rawdog.change_feed_url(self.url, location, config, errors.append)
                                else:
                                        errors.append("You should update its entry in your config file.")
                        errors.append("")
@@ -1262,13 +1261,13 @@ class Rawdog(Persistable):
                        version = 1
                return version == STATE_VERSION
 
-       def change_feed_url(self, oldurl, newurl, config):
+       def change_feed_url(self, oldurl, newurl, config, error_fn):
                """Change the URL of a feed."""
 
                assert self.feeds.has_key(oldurl)
                if self.feeds.has_key(newurl):
-                       print >>sys.stderr, "Error: New feed URL is already subscribed; please remove the old one"
-                       print >>sys.stderr, "from the config file by hand."
+                       error_fn("Error: New feed URL is already subscribed; please remove the old one")
+                       error_fn("from the config file by hand.")
                        return
 
                edit_file("config", ChangeFeedEditor(oldurl, newurl).edit)
@@ -1293,7 +1292,7 @@ class Rawdog(Persistable):
                                if article.feed == oldurl:
                                        article.feed = newurl
 
-               print >>sys.stderr, "Feed URL automatically changed."
+               error_fn("The config file has been updated automatically.")
 
        def list(self, config):
                """List the configured feeds."""