Jawz84 / explainpowershell

PowerShell version of explainshell.com
https://www.explainpowershell.com/
MIT License
34 stars 1 forks source link

The catch statement does not specify the type of associated exception #88

Closed LaurentDardenne closed 1 year ago

LaurentDardenne commented 2 years ago

With

catch [System.Management.Automation.CommandNotFoundException] {"Command error trapped"};catch  {"Command error trapped"}

image

While the Trap statement considers the type of the exception

trap [System.Management.Automation.CommandNotFoundException] {"Command error trapped"}

image

But in this case it is a value (a type) and not a constraint

Jawz84 commented 2 years ago

Trapdoes not have an explanation in code yet, but try {}; catch {} does, I think I may have changed the behaviour there, or, possibly the type constraint is handled differently in the Ast there. Good one. Needs further attention