From 41087704a91f9e9d34020b5c27e0cf20a6952426 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 21 Jan 2021 15:52:07 +0100 Subject: [PATCH] Improve Amazon error detection (#4402) --- openlibrary/core/vendors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlibrary/core/vendors.py b/openlibrary/core/vendors.py index 52bf06e7461..671b8095c83 100644 --- a/openlibrary/core/vendors.py +++ b/openlibrary/core/vendors.py @@ -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):