Catch JSONDecodeError before ValueError
As JSONDecodeError is subclass of ValueError,
it needs to be caught before to be able to catch it
+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
