Merge pull request 'Fix clan select hiding error messages' (#4704) from Qubasa/clan-core:clan_select_error_msg into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4704
This commit is contained in:
@@ -907,7 +907,22 @@ class Flake:
|
|||||||
).stdout.strip()
|
).stdout.strip()
|
||||||
)
|
)
|
||||||
except ClanCmdError as e:
|
except ClanCmdError as e:
|
||||||
raise ClanSelectError(flake_identifier=self.identifier, selectors=selectors, cmd_error=e) from e
|
if "error: attribute 'clan' missing" in str(e):
|
||||||
|
msg = ("This flake does not export the 'clan' attribute. \n"
|
||||||
|
"Please write 'clan = clan.config' into your flake.nix.")
|
||||||
|
raise ClanError(msg) from e
|
||||||
|
if "error: attribute" in str(e):
|
||||||
|
# If the error is about a missing attribute, we raise a ClanSelectError
|
||||||
|
# with the failed selectors and the flake identifier.
|
||||||
|
raise ClanSelectError(
|
||||||
|
flake_identifier=self.identifier,
|
||||||
|
selectors=selectors,
|
||||||
|
cmd_error=e,
|
||||||
|
) from e
|
||||||
|
|
||||||
|
# If the error is not about a missing attribute, we re-raise it as a ClanCmdError
|
||||||
|
# to preserve the original error context.
|
||||||
|
raise
|
||||||
|
|
||||||
if tmp_store := nix_test_store():
|
if tmp_store := nix_test_store():
|
||||||
build_output = tmp_store.joinpath(*build_output.parts[1:])
|
build_output = tmp_store.joinpath(*build_output.parts[1:])
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ from clan_cli.vars.generate import get_generators, run_generators
|
|||||||
|
|
||||||
from clan_lib.cmd import RunOpts, run
|
from clan_lib.cmd import RunOpts, run
|
||||||
from clan_lib.dirs import specific_machine_dir
|
from clan_lib.dirs import specific_machine_dir
|
||||||
from clan_lib.errors import ClanError
|
from clan_lib.errors import ClanCmdError, ClanError
|
||||||
from clan_lib.flake import ClanSelectError, Flake
|
from clan_lib.flake import Flake
|
||||||
from clan_lib.machines.machines import Machine
|
from clan_lib.machines.machines import Machine
|
||||||
from clan_lib.network.network import get_network_overview, networks_from_flake
|
from clan_lib.network.network import get_network_overview, networks_from_flake
|
||||||
from clan_lib.nix import nix_command
|
from clan_lib.nix import nix_command
|
||||||
@@ -284,10 +284,10 @@ def test_clan_create_api(
|
|||||||
|
|
||||||
if in_sandbox:
|
if in_sandbox:
|
||||||
# In sandbox: expect build to fail due to network restrictions
|
# In sandbox: expect build to fail due to network restrictions
|
||||||
with pytest.raises(ClanSelectError) as select_error:
|
with pytest.raises(ClanCmdError) as select_error:
|
||||||
Path(machine.select("config.system.build.toplevel"))
|
Path(machine.select("config.system.build.toplevel"))
|
||||||
# The error should be a select_error without a failed_attr
|
# The error should be a select_error without a failed_attr
|
||||||
assert select_error.value.failed_attr is None
|
assert "nixos-system-test-clan" in str(select_error.value.cmd.stderr)
|
||||||
else:
|
else:
|
||||||
# Outside sandbox: build should succeed
|
# Outside sandbox: build should succeed
|
||||||
toplevel_path = Path(machine.select("config.system.build.toplevel"))
|
toplevel_path = Path(machine.select("config.system.build.toplevel"))
|
||||||
|
|||||||
Reference in New Issue
Block a user