mformat: provide nice error message instead of backtrace for invalid value

I ran into this with `option = true;` (note the trailing `;`). Now we
provide a nicer message instead of an uncaught Python backtrace.

Closes: #13565
pull/13583/head
Dylan Baker 3 months ago committed by Jussi Pakkanen
parent 49a58cf743
commit 1e6e4c8d57
  1. 6
      mesonbuild/mformat.py

@ -861,7 +861,11 @@ class Formatter:
for f in fields(config): for f in fields(config):
getter = f.metadata['getter'] getter = f.metadata['getter']
value = getter(cp, cp.default_section, f.name, fallback=None) try:
value = getter(cp, cp.default_section, f.name, fallback=None)
except ValueError as e:
raise MesonException(
f'Error parsing "{str(configuration_file)}", option "{f.name}", error: "{e!s}"')
if value is not None: if value is not None:
setattr(config, f.name, value) setattr(config, f.name, value)

Loading…
Cancel
Save