mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-31 05:19:09 -07:00
Do not use str() on exceptions (#46950)
This commit is contained in:
parent
2436aa1a4e
commit
a80c25cbd9
30 changed files with 76 additions and 66 deletions
|
@ -1057,7 +1057,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
with open(source, 'rb') as src:
|
||||
src_contents = src.read()
|
||||
except Exception as e:
|
||||
raise AnsibleError("Unexpected error while reading source (%s) for diff: %s " % (source, str(e)))
|
||||
raise AnsibleError("Unexpected error while reading source (%s) for diff: %s " % (source, to_native(e)))
|
||||
|
||||
if b"\x00" in src_contents:
|
||||
diff['src_binary'] = 1
|
||||
|
|
|
@ -41,7 +41,7 @@ class ActionModule(_ActionModule):
|
|||
try:
|
||||
self._handle_template()
|
||||
except ValueError as exc:
|
||||
return dict(failed=True, msg=str(exc))
|
||||
return dict(failed=True, msg=to_text(exc))
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
del tmp # tmp no longer has any effect
|
||||
|
|
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
|||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
||||
try:
|
||||
|
@ -112,7 +113,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
except TimedOutException as e:
|
||||
result['failed'] = True
|
||||
result['msg'] = str(e)
|
||||
result['msg'] = to_text(e)
|
||||
|
||||
elapsed = datetime.now() - start
|
||||
result['elapsed'] = elapsed.seconds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue