self.feed = feed
-class InvalidFeedName (FeedError):
+class InvalidFeedConfig (FeedError):
+ def __init__(self, setting, feed, message=None, **kwargs):
+ if not message:
+ message = "invalid feed configuration {}".format(
+ {setting: getattr(feed, setting)})
+ super(InvalidFeedConfig, self).__init__(
+ feed=feed, message=message, **kwargs)
+ self.setting = setting
+
+
+class InvalidFeedName (InvalidFeedConfig):
def __init__(self, name, **kwargs):
message = "invalid feed name '{}'".format(name)
- super(InvalidFeedName, self).__init__(message=message, **kwargs)
+ super(InvalidFeedName, self).__init__(
+ setting='name', message=message, **kwargs)
class ProcessingError (FeedError):
"'r2e new' first.")
-class NoToEmailAddress (FeedsError, FeedError):
- def __init__(self, **kwargs):
+class NoToEmailAddress (InvalidFeedConfig, FeedsError):
+ def __init__(self, feed, **kwargs):
message = 'no target email address has been defined'
- super(NoToEmailAddress, self).__init__(message=message, **kwargs)
+ super(NoToEmailAddress, self).__init__(
+ setting='to', feed=feed, message=message, **kwargs)
def log(self):
super(NoToEmailAddress, self).log()
...
rss2email.error.InvalidFeedName: invalid feed name 'invalid name'
+ You must define a URL:
+
+ >>> Feed(name='feed-without-a-url', to='a@b.com').run(send=False)
+ Traceback (most recent call last):
+ ...
+ rss2email.error.InvalidFeedConfig: invalid feed configuration {'url': None}
+
+
Cleanup `CONFIG`.
>>> CONFIG['DEFAULT']['to'] = ''
200
"""
_LOG.info('fetch {}'.format(self))
+ if not self.url:
+ raise _error.InvalidFeedConfig(setting='url', feed=self)
if self.section in self.config:
config = self.config[self.section]
else: