conf: log clearer and less verbose error on validation failure
This commit is contained in:
parent
8506b843c5
commit
0034c349f2
1 changed files with 16 additions and 1 deletions
|
@ -526,7 +526,22 @@ def load_config(features: set[str], target: str) -> TomlConf:
|
||||||
except FileNotFoundError as exc:
|
except FileNotFoundError as exc:
|
||||||
tomlconf = None
|
tomlconf = None
|
||||||
|
|
||||||
except (ConfError, jsonschema.ValidationError) as exc:
|
except jsonschema.ValidationError as exc:
|
||||||
|
if not exc.path:
|
||||||
|
log.error("Invalid rust2rpm.toml file (unknown setting or table):")
|
||||||
|
log.error(exc.message)
|
||||||
|
else:
|
||||||
|
err_path = ""
|
||||||
|
for elem in exc.path:
|
||||||
|
if isinstance(elem, int):
|
||||||
|
err_path += f"[{elem}]"
|
||||||
|
else:
|
||||||
|
err_path += f"/{elem}"
|
||||||
|
log.error(f"Invalid rust2rpm.toml file (invalid setting at {err_path!r}):")
|
||||||
|
log.error(exc.message)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
except ConfError as exc:
|
||||||
log.error("Invalid rust2rpm.toml file:")
|
log.error("Invalid rust2rpm.toml file:")
|
||||||
log.error(str(exc))
|
log.error(str(exc))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue