Movatterモバイル変換


[0]ホーム

URL:


Skip to main contentSkip to in-page navigation

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

CustomFunctions.Error class

Use this class to handle errors and write custom error messages.

Remarks

[API set: CustomFunctionsRuntime 1.2 ]

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

Constructors

(constructor)(code, message)

Constructs a new instance of theError class

Properties

code

The error code returned by your custom function.

message

Your custom error message, such as "This stock price is unavailable". Custom messages are only available with certain error codes.

Constructor Details

(constructor)(code, message)

Constructs a new instance of theError class

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

Parameters

message

string

Property Details

code

The error code returned by your custom function.

code: ErrorCode;

Property Value

Remarks

[API set: CustomFunctionsRuntime 1.2 ]

message

Your custom error message, such as "This stock price is unavailable". Custom messages are only available with certain error codes.

message?: string;

Property Value

string

Remarks

[API set: CustomFunctionsRuntime 1.2 ]

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo