Skip to content

Commit

Permalink
doi2url: Don't ignore non-404 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Oct 15, 2023
1 parent ebdd121 commit 1fc8f19
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions repo2docker/contentproviders/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ def doi2url(self, doi):
try:
resp = self._request(f"https://doi.org/{doi}")
resp.raise_for_status()
# If the DOI doesn't resolve, just return URL
except HTTPError:
return doi
except HTTPError as e:
# If the DOI doesn't exist, just return URL
if e.response.status_code == 404:
return doi
# Reraise any other errors because if the DOI service is down (or
# we hit a rate limit) we don't want to silently continue to the
# default Git provider as this leads to a misleading error.
logging.error(f"DOI {doi} does not resolve: {e}")
raise
return resp.url
else:
# Just return what is actulally just a URL
Expand Down

0 comments on commit 1fc8f19

Please sign in to comment.