Skip to content

Commit f8a7f11

Browse files
committed
raising 404 for outer logic control
1 parent b92db38 commit f8a7f11

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

bazelisk.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,18 @@ def download(url, destination_path, retries=5, wait_seconds=5):
371371
for _ in range(retries):
372372
try:
373373
sys.stderr.write("Downloading {}...\n".format(url))
374+
response = None
374375
try:
375376
response = urlopen(request)
376377
with open(destination_path, "wb") as file:
377378
shutil.copyfileobj(response, file)
378379
return
379-
except HTTPError as exception:
380-
if exception.code == 404:
381-
raise
382380
finally:
383-
response.close()
381+
if response:
382+
response.close()
383+
except HTTPError as ex:
384+
if ex.code == 404:
385+
raise
384386
except Exception as ex:
385387
print("failed to download Bazel resource: {}".format(ex))
386388
finally:

0 commit comments

Comments
 (0)