From b31cd189a712fe9499e0b9f8f5863797517038d0 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 25 Aug 2022 19:43:03 -0700 Subject: Improve error message for yaml config file (#32382) * improve error message * Update lib/spack/spack/config.py Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> --- lib/spack/spack/config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 208daf77f7..00d1abc8b1 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -1020,7 +1020,15 @@ def read_config_file(filename, schema=None): raise ConfigFileError("Config file is empty or is not a valid YAML dict: %s" % filename) except MarkedYAMLError as e: - raise ConfigFileError("Error parsing yaml%s: %s" % (str(e.context_mark), e.problem)) + msg = "Error parsing yaml" + mark = e.context_mark if e.context_mark else e.problem_mark + if mark: + line, column = mark.line, mark.column + msg += ": near %s, %s, %s" % (mark.name, str(line), str(column)) + else: + msg += ": %s" % (filename) + msg += ": %s" % (e.problem) + raise ConfigFileError(msg) except IOError as e: raise ConfigFileError("Error reading configuration file %s: %s" % (filename, str(e))) -- cgit v1.2.3-70-g09d2