mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-11 14:35:06 +00:00
[PR #11149/79b16d9c backport][stable-12] fix return value exception (#11173)
fix return value `exception` (#11149)
* fix return value `exception`
* add changelog frag
* adjustments after review
* typo
* adjust changelog frag
* vmadm: send rc, stdout, and stderr to fail_json()
* rundeck: pass tracebacks
* Update changelogs/fragments/11149-rv-exception.yml
* Update changelogs/fragments/11149-rv-exception.yml
---------
(cherry picked from commit 79b16d9ca5)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
4480036401
commit
9d7855b844
3 changed files with 15 additions and 8 deletions
|
|
@ -5,9 +5,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
|
||||
def api_argument_spec():
|
||||
|
|
@ -82,6 +82,10 @@ def api_request(module, endpoint, data=None, method="GET", content_type="applica
|
|||
json_response = json.loads(content)
|
||||
return json_response, info
|
||||
except AttributeError as error:
|
||||
module.fail_json(msg="Rundeck API request error", exception=to_native(error), execution_info=info)
|
||||
module.fail_json(
|
||||
msg=f"Rundeck API request error: {error}", exception=traceback.format_exc(), execution_info=info
|
||||
)
|
||||
except ValueError as error:
|
||||
module.fail_json(msg="No valid JSON response", exception=to_native(error), execution_info=content)
|
||||
module.fail_json(
|
||||
msg=f"No valid JSON response: {error}", exception=traceback.format_exc(), execution_info=content
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue