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
After long discussion on PSMVP alias it seems that there's a bug with catch [System.Exception]. If there are two catch statements and the "general" case uses "catch [System.Exception" instead of "catch" the general case will run instead of the more specific exception!! That's pretty mind blowing. FixPowerShell#296
After long discussion on PSMVP alias it seems that there's a bug with catch [System.Exception]. If there are two catch statements and the "general" case uses "catch [System.Exception" instead of "catch" the general case will run instead of the more specific exception!! That's pretty mind blowing. Fix#296
If you specify multiple catch statements and use [System.Exception] for the catch all, that clause will always execute.
System Details
$PSVersionTable
:Issue Description
Here is the issue. Look at this code:
Which catch statement do you expect to execute given that the exception type thrown is
[System.Management.Automation.ItemNotFoundException]
?It's actually the last catch statement that executes instead of the specific catch. That's messed up.
This can be fixed by making the last catch be just "catch" with no exception type specified.
The text was updated successfully, but these errors were encountered: