Skip to content

Commit

Permalink
fix(registry_handler): Handle api exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Noahnc committed Dec 4, 2023
1 parent 592712d commit 7843356
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions infrapatch/core/utils/terraform/registry_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ def _send_request(self, url: str, registry_base_domain: str):
request_object.add_header("Authorization", f"Bearer {token}")
else:
log.debug(f"No credentials found for registry '{registry_base_domain}', using unauthenticated request.")

response = request.urlopen(request_object)
try:
response = request.urlopen(request_object)
except Exception as e:
raise TerraformRegistryException(f"Registry request returned an error '{url}': {e}")
if response.status == 404:
raise TerraformRegistryException(f"Registry resource '{url}' not found.")
elif response.status >= 400:
Expand Down

0 comments on commit 7843356

Please # to comment.