Error Object Members

Learn about Error object members in SuiteScript 2.1, including handling error messages and document IDs in machine translation processes.

·2 min read·View Oracle Docs

The Error object in SuiteScript 2.1 provides essential properties for managing errors encountered during the translation process. Understanding these members is crucial for developers working with the N/machineTranslation module.

What Are the Members of the Error Object?

The following table outlines the available members of the Error object, their types, and descriptions:

Member NameTypeDescriptionSupported Script Types
Error.documentIdstringThe ID of the document in which the error occurred.Server scripts
Error.messagestringThe error message returned from the translation service.Server scripts

Handling Errors in Code

When using the machineTranslation module, it’s important to handle errors gracefully. Below is an illustrative code sample demonstrating how to access error members:

suitescript
1// Add additional code
2...
3
4const myDocument = machineTranslation.createDocument({
5 id: 'myDoc',
6 text: 'This is a document to be translated.'
7});
8
9const translationResults = machineTranslation.translate({
10 documents: [myDocument],
11 targetLanguage: machineTranslation.Language.CZECH
12});
13
14if (translationResults.errors.length) {
15 // Handle the error message
16 const docErrorId = translationResults.errors[0].documentId;
17 const docErrorMessage = translationResults.errors[0].message;
18}
19
20...
21// Add additional code

This script creates a translation request for a document and checks for any errors that might arise during the process, allowing for effective error management.

Conclusion

Utilizing the Error object members effectively helps to enhance error handling in translation scripts, ensuring smoother operations and better user experience.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What properties are available in the Error object in SuiteScript 2.1?
The Error object in SuiteScript 2.1 includes the 'documentId' property, which indicates the ID of the document where the error occurred, and the 'message' property, which contains the error message from the translation service. These are used in server scripts.
Which script types support Error object members in SuiteScript?
The members of the Error object, such as 'documentId' and 'message', are supported in server scripts in SuiteScript 2.1.
How can I access the document ID and error message from the machineTranslation module?
You can access these by checking the 'errors' array in the translation results. For each error, you can retrieve the 'documentId' and 'message' properties to manage errors effectively.
Do I need special configurations to use the Error object with machineTranslation in SuiteScript 2.1?
The article doesn't specify special configurations for using the Error object with the machineTranslation module, but you should handle the errors carefully as demonstrated in the code example.
Source: Error Object Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →