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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category