mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
templar: ensure that exceptions are handled, fix 'AttributeError' (#48792)
* templar: ensure that exceptions are handled * Fix AttributeError: object has no attribute 'message' 'message' attribute is deprecated since Python 2.6 and not available with Python 3. Simple reproducer: - hosts: localhost vars: not_json: "{{ 'test str' | from_json }}" tasks: - command: "echo {{ not_json }}"
This commit is contained in:
parent
37f66ee15b
commit
62c05033d6
2 changed files with 6 additions and 1 deletions
|
@ -107,7 +107,7 @@ class AnsibleJ2Vars(Mapping):
|
|||
except AnsibleUndefinedVariable:
|
||||
raise
|
||||
except Exception as e:
|
||||
msg = getattr(e, 'message') or to_native(e)
|
||||
msg = getattr(e, 'message', None) or to_native(e)
|
||||
raise AnsibleError("An unhandled exception occurred while templating '%s'. "
|
||||
"Error was a %s, original message: %s" % (to_native(variable), type(e), msg))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue