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.
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?
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 Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Search Filter Object Usage in SuiteScript
The Search Filter object enables refined query capabilities in SuiteScript, encapsulating search criteria.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category