Skip to content

Commit 1fc8f19

Browse files
committed
doi2url: Don't ignore non-404 errors
1 parent ebdd121 commit 1fc8f19

File tree

1 file changed

+9
-3
lines changed
  • repo2docker/contentproviders

1 file changed

+9
-3
lines changed

repo2docker/contentproviders/doi.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ def doi2url(self, doi):
5151
try:
5252
resp = self._request(f"https://doi.org/{doi}")
5353
resp.raise_for_status()
54-
# If the DOI doesn't resolve, just return URL
55-
except HTTPError:
56-
return doi
54+
except HTTPError as e:
55+
# If the DOI doesn't exist, just return URL
56+
if e.response.status_code == 404:
57+
return doi
58+
# Reraise any other errors because if the DOI service is down (or
59+
# we hit a rate limit) we don't want to silently continue to the
60+
# default Git provider as this leads to a misleading error.
61+
logging.error(f"DOI {doi} does not resolve: {e}")
62+
raise
5763
return resp.url
5864
else:
5965
# Just return what is actulally just a URL

0 commit comments

Comments
 (0)