Skip to content

Commit

Permalink
Improve logging regarding to yaml loading and dumping (#3875)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Oct 27, 2023
1 parent bbc7f8c commit 7b9041b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ansiblelint/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def run(self) -> None:
continue

if file_is_yaml:
_logger.debug("Dumping %s using YAML (%s)", file, yaml.version)
# noinspection PyUnboundLocalVariable
file.content = yaml.dumps(ruamel_data)

Expand Down
4 changes: 3 additions & 1 deletion src/ansiblelint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from pathlib import Path
from typing import Any

import ruamel.yaml.parser
import yaml
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.module_utils.parsing.convert_bool import boolean
Expand Down Expand Up @@ -910,8 +911,9 @@ def construct_mapping(
yaml.parser.ParserError,
yaml.scanner.ScannerError,
yaml.constructor.ConstructorError,
ruamel.yaml.parser.ParserError,
) as exc:
msg = "Failed to load YAML file"
msg = f"Failed to load YAML file: {lintable.path}"
raise RuntimeError(msg) from exc

if len(result) == 0:
Expand Down

0 comments on commit 7b9041b

Please sign in to comment.