diff --git a/lib/ansible/template/vars.py b/lib/ansible/template/vars.py index 86837a9a79..7ce650ff7d 100644 --- a/lib/ansible/template/vars.py +++ b/lib/ansible/template/vars.py @@ -105,7 +105,10 @@ class AnsibleJ2Vars(Mapping): try: value = self._templar.template(variable) except Exception as e: - raise type(e)(to_native(variable) + ': ' + e.message) + try: + raise type(e)(to_native(variable) + ': ' + e.message) + except AttributeError: + raise type(e)(to_native(variable) + ': ' + to_native(e)) return value def add_locals(self, locals):