-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Considering that Throw is designed for generate Terminating errors and -ErrorAction and $ErrorActionPreference for Non-Terminating errors, why the following code does not terminate at 5?
$ErrorActionPreference = "SilentlyContinue"
1..10 |
ForEach-Object {
$_
if($_ -eq 5) {
throw "abc"
}
}
$ErrorActionPreference = "Continue"function Throw-Example
{
[CmdletBinding()]
param()
"Line before the terminating error"
Throw "This is my custom terminating error"
"Line after the throw"
}
Throw-Example -ErrorAction SilentlyContinueExpected behavior
Throw terminates the execution regardless of -ErrorAction or $ErrorActionPreference, like it does with the default Continue value.Actual behavior
Throw does not terminates the execution like a non-terminating error when -ErrorAction or $ErrorActionPreference value is SilentlyContinue.Error details
No response
Environment data
# $PSVersionTable
Name Value
---- -----
PSVersion 7.3.3
PSEdition Core
GitCommitId 7.3.3
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more