Error Object Members
Learn about Error object members in SuiteScript 2.1, including handling error messages and document IDs in machine translation processes.
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 Name | Type | Description | Supported Script Types |
|---|---|---|---|
Error.documentId | string | The ID of the document in which the error occurred. | Server scripts |
Error.message | string | The 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:
1// Add additional code2...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.CZECH12});13 14if (translationResults.errors.length) {15 // Handle the error message16 const docErrorId = translationResults.errors[0].documentId;17 const docErrorMessage = translationResults.errors[0].message;18}19 20...21// Add additional codeThis 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.
Frequently Asked Questions (4)
What properties are available in the Error object in SuiteScript 2.1?
Which script types support Error object members in SuiteScript?
How can I access the document ID and error message from the machineTranslation module?
Do I need special configurations to use the Error object with machineTranslation in SuiteScript 2.1?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
