Improve error message from Start-NativeExecution (#26500)

This commit is contained in:
Jonathan Gilbert
2026-01-09 15:48:37 -08:00
committed by GitHub
parent 4838a8d5f6
commit 7ace9e0f5e
+4 -2
View File
@@ -16,6 +16,8 @@ function script:Start-NativeExecution {
$ErrorActionPreference = "Continue"
Write-Verbose "Executing: $ScriptBlock"
try {
$cwd = Get-Location
if ($VerboseOutputOnError.IsPresent) {
$output = & $ScriptBlock 2>&1
} else {
@@ -36,10 +38,10 @@ function script:Start-NativeExecution {
$callerFile = $callerLocationParts[0]
$callerLine = $callerLocationParts[1]
$errorMessage = "Execution of {$ScriptBlock} by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE"
$errorMessage = "Execution of {$ScriptBlock} in '$cwd' by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE"
throw $errorMessage
}
throw "Execution of {$ScriptBlock} failed with exit code $LASTEXITCODE"
throw "Execution of {$ScriptBlock} in '$cwd' failed with exit code $LASTEXITCODE"
}
} finally {
$ErrorActionPreference = $backupEAP