Skip to content

Commit

Permalink
Catch JSONDecodeError before ValueError
Browse files Browse the repository at this point in the history
As JSONDecodeError is subclass of ValueError,
it needs to be caught before to be able to catch it
glensc committed Apr 7, 2021
1 parent 8a07d03 commit 9fc9cb7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plex_trakt_sync/trakt_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from json import JSONDecodeError
from typing import Union
import trakt

@@ -171,6 +172,8 @@ def add_to_collection(self, m):
def find_movie(self, movie):
try:
search = trakt.sync.search_by_id(movie.id, id_type=movie.provider)
except JSONDecodeError as e:
raise ValueError(f"Unable to search result for {movie.provider}: {movie.id}: {e.doc!r}") from e
except ValueError as e:
# Search_type must be one of ('trakt', ..., 'imdb', 'tmdb', 'tvdb')
raise ValueError(f"Invalid id_type: {movie.provider}") from e

0 comments on commit 9fc9cb7

Please sign in to comment.