feed: Convert missing/extra key errors to InvalidFeedConfig
authorW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 01:03:51 +0000 (20:03 -0500)
committerW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 01:07:20 +0000 (20:07 -0500)
This way we get the message and not a full traceback, to avoid scaring
users who aren't familiar with Python tracebacks.  Theres not much
information to go on in the new message, but if you crank up the
verbosity, you get:

  $ PYTHONPATH=. ./r2e -c conf -d data -VVV list
  load feed configuration from ['conf']
  loaded configuration from ['conf']
  load feed data from data
  extra configuration key: use_8bit

which seems good enough for me.

Reported-by: Dmitry Bogatov <KAction@gnu.org>
Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/feed.py

index 3621a0b94b17823b2446d7a11a20a32fec33fe6a..776d115d90bc4db67083eabb85e5797757d4f46f 100644 (file)
@@ -246,10 +246,14 @@ class Feed (object):
             for key in expected:
                 if (key not in keys and
                     key not in self._non_default_configured_attributes):
-                    raise ValueError('missing key: {}'.format(key))
+                    raise _error.InvalidFeedConfig(
+                        setting=key, feed=self,
+                        message='missing configuration key: {}'.format(key))
             for key in keys:
                 if key not in expected:
-                    raise ValueError('extra key: {}'.format(key))
+                    raise _error.InvalidFeedConfig(
+                        setting=key, feed=self,
+                        message='extra configuration key: {}'.format(key))
         data = dict(
             (self._configured_attribute_inverse_translations[k],
              self._get_configured_attribute_value(