You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.WasThrownFromThrowStatement not available for System.Exception #6288
>$PSVersionTable
Name Value
---------
PSVersion 6.0.0
PSEdition Core
GitCommitId v6.0.0
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
As discussed, the problem happens with [System.Exception]-derived types as well, except for [System.Management.Automation.RuntimeException], which is what PowerShell implicitly uses when you throw nothing or any object that is not an exception.
The .WasThrownFromThrowStatement property along with RuntimeException are implementation details for the PowerShell runtime and aren't intended to be used by end users. .WasThrownFromThrowStatement exists so that the throw statement can throw an exception that won't be caught by pipeline exception handlers allowing the exception to propagate up through a set of nested pipelines. Since it's PowerShell-specific, it won't appear on any non-PowerShell types.
Reacted by alx9r, Michael Klement, wisemoth and Tom Winter
Activity
mklement0 commentedon Mar 1, 2018
As discussed, the problem happens with
[System.Exception]-derived types as well, except for[System.Management.Automation.RuntimeException], which is what PowerShell implicitly uses when you throw nothing or any object that is not an exception.BrucePay commentedon Mar 14, 2018
The
.WasThrownFromThrowStatementproperty along withRuntimeExceptionare implementation details for the PowerShell runtime and aren't intended to be used by end users..WasThrownFromThrowStatementexists so that thethrowstatement can throw an exception that won't be caught by pipeline exception handlers allowing the exception to propagate up through a set of nested pipelines. Since it's PowerShell-specific, it won't appear on any non-PowerShell types.alx9r commentedon Mar 14, 2018
Thanks for the clarity Bruce Payette (@BrucePay)