mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
- Fix to return error message back to the module. (#31035)
This commit is contained in:
@@ -150,10 +150,16 @@ class Cli:
|
||||
if check_rc and rc != 0:
|
||||
self._module.fail_json(msg=to_text(err, errors='surrogate_then_replace'))
|
||||
|
||||
try:
|
||||
out = self._module.from_json(out)
|
||||
except ValueError:
|
||||
out = str(out).strip()
|
||||
if not check_rc and rc != 0:
|
||||
try:
|
||||
out = self._module.from_json(err)
|
||||
except ValueError:
|
||||
out = to_text(err, errors='surrogate_then_replace').strip()
|
||||
else:
|
||||
try:
|
||||
out = self._module.from_json(out)
|
||||
except ValueError:
|
||||
out = to_text(out, errors='surrogate_then_replace').strip()
|
||||
|
||||
responses.append(out)
|
||||
return responses
|
||||
|
||||
Reference in New Issue
Block a user