spec.SpecError(message, *, path=None, line=None)
A file under regen/ is missing a field or holds a value outside its vocabulary.
The message is the text the command line prints. path and line tell a consumer such as an editor where to look.
Attributes
| path |
|
The file the error is about, or None. |
| line |
|
The 1-based line of the error, or None. Only a TOML syntax error carries a line, and only on Python 3.14 and later. |
Examples
from pathlib import Path
from tempfile import TemporaryDirectory
from spotregen import SpecError, load_spec, make_sample_repo
with TemporaryDirectory() as tmp:
root = make_sample_repo(Path(tmp) / "demo")
unit = root / "regen" / "units" / "core.calc.toml"
unit.write_text(unit.read_text().replace('"fast"', '"warp"'))
try:
load_spec(root)
except SpecError as exc:
print(str(exc).replace(tmp, "<tmp>"))
print(exc.path.name, exc.line)
/private<tmp>/demo/regen/units/core.calc.toml: field 'pace' is 'warp', expected one of ('fast', 'medium', 'slow')
core.calc.toml None