Skip to content

Commit

Permalink
mformat: provide nice error message instead of backtrace for invalid …
Browse files Browse the repository at this point in the history
…value

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

Closes: mesonbuild#13565
  • Loading branch information
dcbaker committed Aug 20, 2024
1 parent d9ba422 commit abeb885
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mesonbuild/mformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,11 @@ def load_configuration(self, configuration_file: T.Optional[Path]) -> FormatterC

for f in fields(config):
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:
setattr(config, f.name, value)

Expand Down

0 comments on commit abeb885

Please sign in to comment.