mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
[PR #11095/2b4333a0 backport][stable-12] Use raise from in plugins (#11129)
Use raise from in plugins (#11095)
* Use raise from.
* Add changelog fragment.
(cherry picked from commit 2b4333a033)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -143,16 +143,16 @@ def _fetch_information(token, url):
|
||||
try:
|
||||
response = open_url(paginated_url, headers={"X-Auth-Token": token, "Content-type": "application/json"})
|
||||
except Exception as e:
|
||||
raise AnsibleError(f"Error while fetching {url}: {e}")
|
||||
raise AnsibleError(f"Error while fetching {url}: {e}") from e
|
||||
try:
|
||||
raw_json = json.loads(to_text(response.read()))
|
||||
except ValueError:
|
||||
raise AnsibleError("Incorrect JSON payload")
|
||||
except ValueError as e:
|
||||
raise AnsibleError("Incorrect JSON payload") from e
|
||||
|
||||
try:
|
||||
results.extend(raw_json["servers"])
|
||||
except KeyError:
|
||||
raise AnsibleError("Incorrect format from the Scaleway API response")
|
||||
except KeyError as e:
|
||||
raise AnsibleError("Incorrect format from the Scaleway API response") from e
|
||||
|
||||
link = response.headers["Link"]
|
||||
if not link:
|
||||
|
||||
Reference in New Issue
Block a user