From e05dacfe911bfe02e9c326b2cb20b5eefe7cb650 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 27 Oct 2017 23:28:21 -0400 Subject: [PATCH] more info on yaml errors print yaml's 'problem' --- lib/ansible/errors/yaml_strings.py | 2 +- lib/ansible/parsing/dataloader.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/errors/yaml_strings.py b/lib/ansible/errors/yaml_strings.py index 599729fda4f..ed574eb99e3 100644 --- a/lib/ansible/errors/yaml_strings.py +++ b/lib/ansible/errors/yaml_strings.py @@ -31,7 +31,7 @@ __all__ = [ YAML_SYNTAX_ERROR = """\ Syntax Error while loading YAML. -""" + %s""" YAML_POSITION_DETAILS = """\ The error appears to have been in '%s': line %s, column %s, but may diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index 005365c49d5..5f9aac92f61 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -225,7 +225,9 @@ 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, orig_exc=yaml_exc) + err_msg = getattr(yaml_exc, 'problem', '') + + raise AnsibleParserError(YAML_SYNTAX_ERROR % to_native(err_msg), obj=err_obj, show_content=show_content, orig_exc=yaml_exc) def get_basedir(self): ''' returns the current basedir '''