Skip to content

Commit

Permalink
preserve underlying block building error (ansible#56465)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca authored May 22, 2019
1 parent 69b2d7e commit 8fe9618
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/better_task_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- display underlying error when reporting an invalid ``tasks:`` block.
3 changes: 2 additions & 1 deletion lib/ansible/playbook/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ansible import constants as C
from ansible import context
from ansible.errors import AnsibleParserError, AnsibleAssertionError
from ansible.module_utils._text import to_native
from ansible.module_utils.six import string_types
from ansible.playbook.attribute import FieldAttribute
from ansible.playbook.base import Base
Expand Down Expand Up @@ -145,7 +146,7 @@ def _load_tasks(self, attr, ds):
try:
return load_list_of_blocks(ds=ds, play=self, variable_manager=self._variable_manager, loader=self._loader)
except AssertionError as e:
raise AnsibleParserError("A malformed block was encountered while loading tasks", obj=self._ds, orig_exc=e)
raise AnsibleParserError("A malformed block was encountered while loading tasks: %s" % to_native(e), obj=self._ds, orig_exc=e)

def _load_pre_tasks(self, attr, ds):
'''
Expand Down

0 comments on commit 8fe9618

Please sign in to comment.