diff --git a/scripts/Common/Scripts/Config.ps1 b/scripts/Common/Scripts/Config.ps1 index f028ea2a..c72bb5eb 100644 --- a/scripts/Common/Scripts/Config.ps1 +++ b/scripts/Common/Scripts/Config.ps1 @@ -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; + } + } } }