Skip to content

Commit 402a23c

Browse files
EliEli
authored andcommitted
Improve error message.
1 parent 41fabde commit 402a23c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

schimpy/schism_yaml.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
It stores document in an ordered dict and supports variable substitution.
33
"""
44

5+
import re
56
import yaml
67
from yaml.reader import *
78
from yaml.scanner import *
@@ -88,10 +89,12 @@ def compose_scalar_node(self, anchor):
8889
template = string.Template(event.value)
8990
value = template.safe_substitute(**self.env)
9091
if "$" in value:
92+
missing = re.findall(r'\$\{(\w+)\}|\$(\w+)', value)
93+
names = [m[0] or m[1] for m in missing]
9194
raise ComposerError(
9295
"Expected a substitution",
9396
event.start_mark,
94-
"No corresponding config variable",
97+
f"No corresponding config variable(s): {', '.join(names)}",
9598
)
9699
node = ScalarNode(
97100
tag, value, event.start_mark, event.end_mark, style=event.style

0 commit comments

Comments
 (0)