error.create(options)
Method Description |
Creates a new error.SuiteScriptError object, which can be used in a try-catch statement to abort script execution. Note this method creates a new error, but does not throw the error. Your script code will need to include logic to throw the error when appropriate. |
Returns |
An error.SuiteScriptError object. |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required |
Error message text displayed in the Details column of the Execution Log. Sets the value for the SuiteScriptError.message property. The default value is null. |
2015.2 |
|
string |
required |
User-defined error code. Sets the value for the SuiteScriptError.name property. |
2015.2 |
|
boolean |
optional |
Sets whether email notification is suppressed. If set to false, the system emails the users identified on the applicable script record’s Unhandled Errors subtab when the error is thrown. The default values is false. For additional information about the Unhandled Errors subtab, see Creating a Script Record. |
2015.2 |
Errors
Error Code |
Thrown If |
---|---|
|
The |
|
One of the parameters is not specified as the correct type:
|
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/error Module Script Samples.
//Add additional code
...
// errorObj is a error.SuiteScriptError if this code is included in a server script that is not a user event script.
// errorObj is a error.UserEventError if this code is included in a user event script.
var custom_error = error.create({
name: 'MY_ERROR_CODE',
message: 'my custom error details',
notifyOff: false
});
log.debug("Error Code: " + custom_error.name); // 'Error Code: MY_ERROR_CODE' will be logged
...
//Add additional code