Skip to content

Commit

Permalink
Improve Amazon error detection (internetarchive#4402)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored and Sabreen-Parveen committed Feb 5, 2021
1 parent d4b124a commit 07d3f0f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion openlibrary/core/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,13 @@ def _get_amazon_metadata(id_, id_type='isbn', resources=None):

try:
r = requests.get('http://%s/isbn/%s' % (affiliate_server_url, id_))
r.raise_for_status()
return r.json().get('hit') or None
except requests.exceptions.ConnectionError:
logger.exception("Affiliate Server unreachable")
return None
except requests.exceptions.HTTPError:
logger.exception("Affiliate Server: id {} not found".format(id_))
return None


def split_amazon_title(full_title):
Expand Down

0 comments on commit 07d3f0f

Please sign in to comment.