Skip to content

Commit

Permalink
Try catching StopIteration explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
sd109 authored Dec 18, 2023
1 parent a0d41c4 commit 200e9a5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions capi_janitor/openstack/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,14 @@ async def __aenter__(self):
# )
# for entry in response.json()["catalog"]
# }
self._endpoints = {}
try:
catalog = response.json()["catalog"]
endpoints = {}
for entry in catalog:
endpoints[entry["type"]] = [ep["url"] for ep in entry["endpoints"] if ep["interface"] == self._interface]
self._endpoints = endpoints
except Exception as exc:
self._endpoints[entry["type"]] = [ep["url"] for ep in entry["endpoints"] if ep["interface"] == self._interface]
except StopIteration as exc:
print(f"Caught: {exc}")
raise
pass

return self

Expand Down

0 comments on commit 200e9a5

Please sign in to comment.