ジャンプ先: 概要. 注記. 戻り値. 関連項目. MEL 例.

概要

catchQuiet (expression)

catchQuiet は 「元に戻す」が可能、「照会」が不可能「編集」が不可能 です。

catchQuiet は、カッコ内のエクスプレッションがランタイム エラーを生成した場合に 1、しなかった場合に 0 を返します。catchQuiet は catch と同様に動作しますが、警告メッセージとエラーを抑制します。 このエクスプレッションは、ユーザが実行時のエラーをチェックして解決できるように設計されています。catchQuiet を使用すると、スクリプトの実行パスを介してランタイム エラーが伝播バック アップされるのを止めることができます。通常、ランタイム エラーが発生すると、スクリプトまたはプロシ-ジャの実行は終了します。

注記

catchQuiet はコマンドではありません。MEL 言語のキーワードです。MEL スクリプトで使用すると、コマンドの呼び出しというよりも、プロシージャ コールに近くなります。

戻り値

int 0 または 1

関連項目

catch

MEL 例

  // 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.