Is there a way to make the error message from the ...
# suitescript
l
Is there a way to make the error message from the n/error module more user friendly? For example, just show the error message instead of something like this: {“type”“error.SuiteScriptError”,“name”“CUSTOM_ERROR”,“message”:“The record already exists.“,”id”null,“stack”[“createError(N/error)“,”beforeSubmit(/SuiteScripts/preventDuplicateRecords.js:34)“,”createError(N/error)“],“cause”{“name”“CUSTOM_ERROR”,“message”:“The record already exists.“},“notifyOff”false,“userFacing”true}
n
It’s a regular json object. So you can just reference any key in the object you want to pull out the text. For example
Copy code
try{
// some error happens
} catch (e) {
log.error({title: ‘Error in script’, details: e.message});
}
l
Sorry, not a tech person but I’ll try that. Thanks!
n
Gotcha. Here is a helpful link that explains objects and how to access their properties https://www.w3schools.com/js/js_objects.asp
❤️ 1