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 ]