Skip to content

Commit

Permalink
chore: better error message if index out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
vn-ki committed Aug 7, 2019
1 parent d5eb40f commit 16ea97d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions anime_downloader/sites/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,18 @@ def get_data(self):
def __getitem__(self, index):
episode_class = AnimeEpisode.subclasses[self.sitename]
if isinstance(index, int):
ep_id = self._episode_urls[index]
try:
ep_id = self._episode_urls[index]
except IndexError as e:
raise RuntimeError("No episode found with index") from e
return episode_class(ep_id[1], parent=self,
ep_no=ep_id[0])
elif isinstance(index, slice):
anime = copy.deepcopy(self)
anime._episode_urls = anime._episode_urls[index]
try:
anime._episode_urls = anime._episode_urls[index]
except IndexError as e:
raise RuntimeError("No episode found with index") from e
return anime
return None

Expand Down

0 comments on commit 16ea97d

Please sign in to comment.