86
PowerShellで新しい例外を作成して投げる方法は?Powershell:新しい例外を作成して投げる
特定のエラーに対してさまざまなことを行いたいと思います。文字列が続く投げコマンドを使用する一般的な例外をスローするには
if (-not (Test-Path $file))
{
throw [System.IO.FileNotFoundException] "$file not found."
}
をこのフォーマットを使用するなどにFileNotFoundExceptionなどの特定の例外を呼び出すために
は、カスタム例外をスローするために探しているエラーを引き起こしたかについての追加情報を提供することができますか? [this] [1]は助けますか? [1]:http://stackoverflow.com/questions/11703180/powershell-creating-a-custom-exception –
この記事を見てみましょう:http://stackoverflow.com/questions/2182666/powershell-2-0-try-catch-how-to-access-the-exception –