summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris White <white238@llnl.gov>2022-08-25 19:43:03 -0700
committerGitHub <noreply@github.com>2022-08-26 02:43:03 +0000
commitb31cd189a712fe9499e0b9f8f5863797517038d0 (patch)
tree35ab37507bc99c66c01bceef9baf496b23f76b71 /lib
parent3ba58d85e294582bc6875f44428e66b92b7b2e02 (diff)
downloadspack-b31cd189a712fe9499e0b9f8f5863797517038d0.tar.gz
spack-b31cd189a712fe9499e0b9f8f5863797517038d0.tar.bz2
spack-b31cd189a712fe9499e0b9f8f5863797517038d0.tar.xz
spack-b31cd189a712fe9499e0b9f8f5863797517038d0.zip
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/config.py10
1 files changed, 9 insertions, 1 deletions
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)))