1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

Use raise from in modules (#11097)

* Use raise from.

* Add changelog fragment.

* Add comment.
This commit is contained in:
Felix Fontein 2025-11-12 21:00:17 +01:00 committed by GitHub
parent 2b4333a033
commit 40aea793ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 60 additions and 39 deletions

View file

@ -59,14 +59,14 @@ def session_method_wrapper(f):
url = self.endpoint + url
r = f(self, url, *args, **kwargs)
except Exception as ex:
raise HwcClientException(0, f"Sending request failed, error={ex}")
raise HwcClientException(0, f"Sending request failed, error={ex}") from ex
result = None
if r.content:
try:
result = r.json()
except Exception as ex:
raise HwcClientException(0, f"Parsing response to json failed, error: {ex}")
raise HwcClientException(0, f"Parsing response to json failed, error: {ex}") from ex
code = r.status_code
if code not in [200, 201, 202, 203, 204, 205, 206, 207, 208, 226]:
@ -184,7 +184,7 @@ class Config:
try:
url = client.get_endpoint(service_type=service_type, region_name=region, interface="public")
except Exception as ex:
raise HwcClientException(0, f"Getting endpoint failed, error={ex}")
raise HwcClientException(0, f"Getting endpoint failed, error={ex}") from ex
if url == "":
raise HwcClientException(0, f"Cannot find the endpoint for {service_type}")