PowerShell - Why “Divide By Zero Exception” is not being Caught?

后端 未结 3 1117
傲寒
傲寒 2020-12-19 05:46

On my Machine each one of the following code snippets throws and exception instead of printing to the standard output \"1\" and \"2\" Why the exception is not being Caught?<

3条回答
  •  离开以前
    2020-12-19 06:15

    You can try to throw an exception with that kind of line : trap { "Your Exception" } 1/0
    This will throw the exception "divide by 0". Though I don't really understand why your code doesn't throw an exception ._.
    PS : Isn't that supposed to be catch [System.SystemException] ? :)

提交回复
热议问题