Modules
Objects/Functions
SuiteScript 2.0
N/error Module
Member Type:
Name
Search NetSuite -
https://system.netsuite.com/app/help/helpcenter.nl?search=N/error Module
// Code Example 1
/**
* @NApiVersion 2.x
*/
// This script creates a custom error.
require(['N/error'], function(error) {
function createError() {
var myCustomError = error.create({
name: 'MY_ERROR_CODE',
message: 'My custom error details',
notifyOff: true
});
}
createError();
});
// Code Example 2
/**
* @NApiVersion 2.x
*/
// This script conditionally creates and throws an error.
require(['N/error'], function(error) {
function showError() {
var someVariable = false;
if (!someVariable) {
var myCustomError = error.create({
name: 'WRONG_PARAMETER_TYPE',
message: 'Wrong parameter type selected.',
notifyOff: false
});
// This will write 'Error: WRONG_PARAMETER_TYPE Wrong parameter type selected' to the log
log.error('Error: ' + myCustomError.name , myCustomError.message);
throw myCustomError;
}
}
showError();
});
//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4243798608.html