From: W. Trevor King Date: Thu, 24 Jan 2013 01:03:51 +0000 (-0500) Subject: feed: Convert missing/extra key errors to InvalidFeedConfig X-Git-Tag: v3.0~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6c45051420cff79da3493a27ebc41eacac256332;p=rss2email.git feed: Convert missing/extra key errors to InvalidFeedConfig 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 Signed-off-by: W. Trevor King --- diff --git a/rss2email/feed.py b/rss2email/feed.py index 3621a0b..776d115 100644 --- a/rss2email/feed.py +++ b/rss2email/feed.py @@ -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(