CustomFunctions.Error class

エラーを処理し、カスタム エラー メッセージを書き込むには、このクラスを使用します。

注釈

[ API セット: CustomFunctionsRuntime 1.2 ]

/**
 * Returns the #NUM! error as part of a 2-dimensional array.
 * @customfunction
 * @param {number} first First parameter.
 * @param {number} second Second parameter.
 * @param {number} third Third parameter.
 * @returns {number[][]} Three results, as a 2-dimensional array.
 */
function returnInvalidNumberError(first, second, third) {
  // Use the `CustomFunctions.Error` object to retrieve an invalid number error.
  const error = new CustomFunctions.Error(
    CustomFunctions.ErrorCode.invalidNumber, // Corresponds to the #NUM! error in the Excel UI.
  );

  // Enter logic that processes the first, second, and third input parameters.
  // Imagine that the second calculation results in an invalid number error.
  const firstResult = first;
  const secondResult = error;
  const thirdResult = third;

  // Return the results of the first and third parameter calculations
  // and a #NUM! error in place of the second result.
  return [[firstResult], [secondResult], [thirdResult]];
};

コンストラクター

(constructor)(code, message)

クラスの新しいインスタンスを構築しますError

プロパティ

code

カスタム関数によって返されるエラー コード。

message

"この株価は使用できません" などのカスタム エラー メッセージ。 カスタム メッセージは、特定のエラー コードでのみ使用できます。

コンストラクターの詳細

(constructor)(code, message)

クラスの新しいインスタンスを構築しますError

constructor(code: ErrorCode, message?: string);

パラメーター

message

string

プロパティの詳細

code

カスタム関数によって返されるエラー コード。

code: ErrorCode;

プロパティ値

注釈

[ API セット: CustomFunctionsRuntime 1.2 ]

message

"この株価は使用できません" などのカスタム エラー メッセージ。 カスタム メッセージは、特定のエラー コードでのみ使用できます。

message?: string;

プロパティ値

string

注釈

[ API セット: CustomFunctionsRuntime 1.2 ]