hakeの日記

Windows環境でプログラミングの勉強をしています。

2017-01-02から1日間の記事一覧

PowerShell - 例外処理

try節のブロックで例外が発生した場合、(該当する型を記述した)catch節が実行される。finally節は例外発生有無に関わらず実行される。 try { "try節です" 1/0 } catch [Exception] { "catch節です" } finally { "finary節です" }try節です catch節です fin…

PowerShell - 例外処理(throw)

意図的に例外を発生させる場合にはthrowを使用する。 try { "try節です" throw "例外発生" } catch [Exception] { "catch節です" } finally { "finary節です" }PS C:\> $error[0].CategoryInfo Category : OperationStopped Activity : Reason : RuntimeExce…