[template/vars] Use to_native(exception) as a fallback for Python 3 which doesn't have a .message attribute (#34044)

This commit is contained in:
Sloane Hertel 2017-12-19 17:34:46 -05:00 committed by GitHub
parent b06f7688cd
commit 7bc754674c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,7 +105,10 @@ class AnsibleJ2Vars(Mapping):
try: try:
value = self._templar.template(variable) value = self._templar.template(variable)
except Exception as e: except Exception as e:
try:
raise type(e)(to_native(variable) + ': ' + e.message) raise type(e)(to_native(variable) + ': ' + e.message)
except AttributeError:
raise type(e)(to_native(variable) + ': ' + to_native(e))
return value return value
def add_locals(self, locals): def add_locals(self, locals):