Emit errors concerning WSL commands

This commit is contained in:
Manuel Thalmann 2024-08-17 13:51:10 +02:00
parent 9e716bce4f
commit 11ae127dba

View file

@ -37,7 +37,13 @@ $null = New-Module {
wsl -e printf "%q" "$result";
};
Receive-Job -Wait $job;
$result = Receive-Job -Wait $job;
if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) {
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
}
$result;
}
<#
@ -87,11 +93,17 @@ $null = New-Module {
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
}
fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script" | ConvertFrom-Json;
}
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
if (-not $?) {
throw "The configuration could not be retrieved!";
if (-not $?) {
Write-Error "The configuration could not be retrieved!";
} else {
if (-not ($output -and ($output | Test-Json))) {
Write-Error "The value ``$output`` is not valid JSON.";
} else {
$output | ConvertFrom-Json;
}
}
}
}