Skip to content

Commit

Permalink
Display the string which is causing an exception to be raised.
Browse files Browse the repository at this point in the history
In the ansible template module, when there is an error while
expanding a templated string, displaying the string causing the
exception is very useful.
  • Loading branch information
Marc Poirier committed Feb 11, 2016
1 parent 8f1e745 commit 0792983
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def _do_template(self, data, preserve_trailing_newlines=True, escape_backslashes
try:
t = myenv.from_string(data)
except TemplateSyntaxError as e:
raise AnsibleError("template error while templating string: %s" % str(e))
raise AnsibleError("template error while templating string: %s. String: %s" % (str(e), data))
except Exception as e:
if 'recursion' in str(e):
raise AnsibleError("recursive loop detected in template string: %s" % data)
Expand Down

0 comments on commit 0792983

Please sign in to comment.