CustomFunctions.ErrorCode enum

Error codes for custom functions. The error codes will appear in the cell that invoked the function.

Custom error messages appear in addition to these error codes. Custom messages display in the error indicator menu, which is accessed by hovering over the error flag on each cell with an error.

Remarks

Examples

/**
 * 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]];
  };

Fields

divisionByZero = "#DIV/0!"

This error code indicates that the function used is dividing by zero or empty cells. A custom error message can't be used.

invalidName = "#NAME?"

This error code indicates that there is a typo in the function name. Note that this error code is supported as a custom function input error, but not as a custom function output error. A custom error message can't be used.

invalidNumber = "#NUM!"

This error code indicates that there is a problem with a number in the function. A custom error message can't be used.

invalidReference = "#REF!"

This error code indicates that the function refers to an invalid cell. Note that this error code is supported as a custom function input error, but not as a custom function output error. A custom error message can't be used.

invalidValue = "#VALUE!"

This error code indicates that a value in the function is of the wrong data type. A custom error message can be used in addition to the error code, if desired.

notAvailable = "#N/A"

This error code indicates that the function or service isn't available. A custom error message can be used in addition to the error code, if desired.

nullReference = "#NULL!"

This error code indicates that the ranges in the function don't intersect. A custom error message can't be used.