Skip to content

Commit

Permalink
raising 404 for outer logic control
Browse files Browse the repository at this point in the history
  • Loading branch information
celestialorb committed Sep 14, 2023
1 parent b92db38 commit f8a7f11
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bazelisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,18 @@ def download(url, destination_path, retries=5, wait_seconds=5):
for _ in range(retries):
try:
sys.stderr.write("Downloading {}...\n".format(url))
response = None
try:
response = urlopen(request)
with open(destination_path, "wb") as file:
shutil.copyfileobj(response, file)
return
except HTTPError as exception:
if exception.code == 404:
raise
finally:
response.close()
if response:
response.close()
except HTTPError as ex:
if ex.code == 404:
raise
except Exception as ex:
print("failed to download Bazel resource: {}".format(ex))
finally:
Expand Down

0 comments on commit f8a7f11

Please sign in to comment.