"'r2e add name url emailaddress'.")
+class FeedIndexError (FeedsError, IndexError):
+ def __init__(self, index, message=None, **kwargs):
+ if message is None:
+ message = 'feed {!r} not found'.format(index)
+ super(FeedIndexError, self).__init__(
+ message=message, **kwargs)
+ self.index = index
+
+
class OPMLReadError (RSS2EmailError):
def __init__(self, **kwargs):
message = 'error reading OPML'
def index(self, index):
if isinstance(index, int):
- return self[index]
+ try:
+ return self[index]
+ except IndexError as e:
+ raise _error.FeedIndexError(index=index, feeds=self) from e
elif isinstance(index, str):
try:
index = int(index)
for feed in self:
if feed.name == index:
return feed
- super(Feeds, self).index(index)
+ try:
+ super(Feeds, self).index(index)
+ except (IndexError, ValueError) as e:
+ raise _error.FeedIndexError(index=index, feeds=self) from e
def remove(self, feed):
super(Feeds, self).remove(feed)