conf: handle invalid syntax in rust2rpm.toml more gracefully

This commit is contained in:
Fabio Valentini 2023-10-18 11:19:27 +02:00
parent 1604e7e36f
commit 5a8bb9eee9
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF

View file

@ -530,6 +530,11 @@ def load_config(features: set[str], target: str) -> TomlConf:
except FileNotFoundError as exc: except FileNotFoundError as exc:
tomlconf = None tomlconf = None
except tomllib.TOMLDecodeError as exc:
log.error("Cannot read rust2rpm.toml file (TOML syntax error):")
log.error(str(exc))
sys.exit(1)
except jsonschema.ValidationError as exc: except jsonschema.ValidationError as exc:
if not exc.path: if not exc.path:
log.error("Invalid rust2rpm.toml file (unknown setting or table):") log.error("Invalid rust2rpm.toml file (unknown setting or table):")