Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ internal override void Complete()
errorMsg,
errorId);

var errorRecord = new ErrorRecord(exception, errorId, ErrorCategory.NotSpecified, targetObject: NativeCommandName);
var errorRecord = new ErrorRecord(exception, errorId, ErrorCategory.NotSpecified, targetObject: Path);
this.commandRuntime._WriteErrorSkipAllowCheck(errorRecord);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
}

$exeName = $IsWindows ? 'testexe.exe' : 'testexe'
$exePath = @(Get-Command $exeName -Type Application)[0].Path

$errorActionPrefTestCases = @(
@{ ErrorActionPref = 'Stop' }
Expand Down Expand Up @@ -43,7 +44,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {

$error.Count | Should -Be 1
$error[0].FullyQualifiedErrorId | Should -BeExactly 'ProgramExitedWithNonZeroCode'
$error[0].TargetObject | Should -BeExactly $exeName
$error[0].TargetObject | Should -BeExactly $exePath
}

It 'Non-zero exit code outputs a non-teminating error for $ErrorActionPreference = ''Continue''' {
Expand All @@ -52,7 +53,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
$stderr = testexe -returncode 1 2>&1

$error[0].FullyQualifiedErrorId | Should -BeExactly 'ProgramExitedWithNonZeroCode'
$error[0].TargetObject | Should -BeExactly $exeName
$error[0].TargetObject | Should -BeExactly $exePath
$stderr[1].Exception.Message | Should -BeExactly "Program `"$exeName`" ended with non-zero exit code: 1."
}

Expand All @@ -65,7 +66,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
$stderr = testexe -returncode 1 2>&1

$error[0].FullyQualifiedErrorId | Should -BeExactly 'ProgramExitedWithNonZeroCode'
$error[0].TargetObject | Should -BeExactly $exeName
$error[0].TargetObject | Should -BeExactly $exePath
$stderr[1].Exception.Message | Should -BeExactly "Program `"$exeName`" ended with non-zero exit code: 1."
}

Expand All @@ -76,7 +77,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {

$error.Count | Should -Be 1
$error[0].FullyQualifiedErrorId | Should -BeExactly 'ProgramExitedWithNonZeroCode'
$error[0].TargetObject | Should -BeExactly $exeName
$error[0].TargetObject | Should -BeExactly $exePath
}

It 'Non-zero exit code does not generates an error record for $ErrorActionPreference = ''Ignore''' {
Expand Down