Before this commit, if no default target email was setup in the
config:
$ r2e add example http://example.net/
Traceback (most recent call last):
File "/usr/bin/r2e", line 5, in <module>
rss2email.main.run()
File "/usr/lib/python3/dist-packages/rss2email/main.py", line 163, in run
args.func(feeds=feeds, args=args)
File "/usr/lib/python3/dist-packages/rss2email/command.py", line 50, in add
raise _error.NoToEmailAddress(feeds=feeds)
TypeError: __init__() missing 1 required positional argument: 'feed'
After this commit:
$ r2e add example http://example.net/
no target email address has been defined
I added the kwargs handling to FeedError so it will be passed through
to FeedsError because NoToEmailAddress has a diamond-inheritence that
includes both RSS2EmailError subclasses.
Reported-by: Jakub Wilk <jwilk@debian.org>
Signed-off-by: W. Trevor King <wking@tremily.us>
feed = feeds.new_feed(name=args.name, url=args.url, to=args.email)
_LOG.info('add new feed {}'.format(feed))
if not feed.to:
- raise _error.NoToEmailAddress(feeds=feeds)
+ raise _error.NoToEmailAddress(feed=feed, feeds=feeds)
feeds.save()
def run(feeds, args):
class FeedError (RSS2EmailError):
- def __init__(self, feed, message=None):
+ def __init__(self, feed, message=None, **kwargs):
if message is None:
message = 'error with feed {}'.format(feed.name)
- super(FeedError, self).__init__(message=message)
+ super(FeedError, self).__init__(message=message, **kwargs)
self.feed = feed