Skip to content

Commit

Permalink
Catch JSONDecodeError (#17)
Browse files Browse the repository at this point in the history
* Catch JSONDecodeError

* review
  • Loading branch information
pfouque authored Jul 12, 2024
1 parent 4ae6fc1 commit 39e0c4d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions itunespy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import pycountry
import requests

Check failure on line 24 in itunespy/__init__.py

View workflow job for this annotation

GitHub Actions / Mypy

itunespy/__init__.py#L24

Library stubs not installed for "requests"
from json.decoder import JSONDecodeError
from urllib.parse import urlencode
from itunespy import artist
from itunespy import music_artist
Expand Down Expand Up @@ -61,6 +62,8 @@ def search(
try:
json = r.json()['results']
result_count = r.json()['resultCount']
except JSONDecodeError:
raise RuntimeError(general_no_connection)
except:
raise ConnectionError(general_no_connection)

Expand Down Expand Up @@ -105,6 +108,8 @@ def lookup(
try:
json = r.json()['results']
result_count = r.json()['resultCount']
except JSONDecodeError:
raise RuntimeError(general_no_connection)
except KeyError:
raise ConnectionError(general_no_connection)

Expand Down

0 comments on commit 39e0c4d

Please sign in to comment.