catchQuiet
(expression)
catchQuiet は、取り消し可能、照会不可能、および編集不可能です。
catchQuiet は、カッコ内のエクスプレッションがランタイム エラーを生成した場合に 1、しなかった場合に 0 を返します。catchQuiet は catch と同様に動作しますが、警告メッセージとエラーを抑制します。 このエクスプレッションは、ユーザが実行時のエラーをチェックして解決できるように設計されています。catchQuiet を使用すると、スクリプトの実行パスを介してランタイム エラーが伝播バック アップされるのを止めることができます。通常、ランタイム エラーが発生すると、スクリプトまたはプロシ-ジャの実行は終了します。| int | 0 または 1 |
// Set $divisor to 0 just to trigger an exception
//
int $divsor = 0;
int $factor;
if ( catchQuiet ($factor == 42/$divsor) ) {
print "Attempt to divide by zero caught\n";
} else {
// continue on as usual...
}
// This example shows how catchQuiet can be used to handle failure of commands
// or procedures. This will catch errors and calls to procedures that do
// not exist. Note, there is no Error: Division by zero in script editor.
catchQuiet ( `underConstruction` );
// Without the catchQuiet, if the execution of underConstruction failed at
// runtime, the whole script containing the call would fail. Using catchQuiet
// enables this script to continue execution even if something fails.