diff options
author | James Cammarata <jimi@sngx.net> | 2017-06-08 12:51:14 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2017-06-08 12:51:37 -0500 |
commit | 781bb44b029becef60af9c9ce765129c7c9c7287 (patch) | |
tree | a0f74601dbcdd81ef28dc7cdef3fd2bef90c7466 /lib/ansible/parsing | |
parent | db15528de322a2231b16ceb54eb4a5de23c53e1c (diff) | |
download | ansible-781bb44b029becef60af9c9ce765129c7c9c7287.tar.gz |
Include the original YAML error in syntax error messages
Diffstat (limited to 'lib/ansible/parsing')
-rw-r--r-- | lib/ansible/parsing/dataloader.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index 3dfecc336c..c436926339 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -202,7 +202,12 @@ class DataLoader: err_obj = AnsibleBaseYAMLObject() err_obj.ansible_pos = (file_name, yaml_exc.problem_mark.line + 1, yaml_exc.problem_mark.column + 1) - raise AnsibleParserError(YAML_SYNTAX_ERROR, obj=err_obj, show_content=show_content) + if hasattr(yaml_exc, 'problem'): + err_str = "%s\nThe YAML error was:\n > %s" % (YAML_SYNTAX_ERROR.strip(), yaml_exc.problem) + else: + err_str = YAML_SYNTAX_ERROR + + raise AnsibleParserError(err_str, obj=err_obj, show_content=show_content) def get_basedir(self): ''' returns the current basedir ''' |