From 07c8b2c9ae26513422f14229cb39eded8f6bc9b3 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 29 Nov 2024 21:33:22 +0100 Subject: [PATCH] Clan-api: disk schema: improve error messages for invalid options --- pkgs/clan-cli/clan_cli/api/disk.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/api/disk.py b/pkgs/clan-cli/clan_cli/api/disk.py index a515799e3..b8408c25b 100644 --- a/pkgs/clan-cli/clan_cli/api/disk.py +++ b/pkgs/clan-cli/clan_cli/api/disk.py @@ -157,7 +157,10 @@ def set_machine_disk_schema( msg = ( f"Placeholder {placeholder_name} not found in disk schema {schema_name}" ) - raise ClanError(msg) + raise ClanError( + msg, + description=f"Available placeholders: {disk_schema.placeholders.keys()}", + ) # Invalid value. Check if the value is one of the provided options if ph.options and placeholder_value not in ph.options: @@ -180,7 +183,7 @@ def set_machine_disk_schema( disko_file_path = hw_config_path.parent.joinpath("disko.nix") if disko_file_path.exists() and not force: msg = f"Disk schema already exists at {disko_file_path}" - raise ClanError(msg) + raise ClanError(msg, description="Use 'force' to overwrite") with disko_file_path.open("w") as disk_config: disk_config.write(config_str)