machineTranslation.Error

Note:

The content in this help topic pertains to SuiteScript 2.1.

Object Description

An error returned from the translation service when calling machineTranslation.translate(options).

The translation service returns an error if a provided document couldn't be translated. An error might occur if the text to translate isn't formatted correctly (for example, if it contains unrecognized characters). This object includes properties for the ID of the document that the error relates to (Error.documentId) and the text of the error message (Error.message).

When passing documents to machineTranslation.translate(options), this object is included in the returned machineTranslation.Response object (in the Response.errors property) if an error occurred while translating the documents. If no errors occurred, the Response.errors property is empty.

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/machineTranslation Module

Methods and Properties

Error Object Members

Since

2025.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/machineTranslation Module Script Samples.

            // Add additional code
...

const myDocument = machineTranslation.createDocument({
    id: 'myDoc',
    text: 'This is a document to be translated.'
});

const translationResults = machineTranslation.translate({
    documents: [myDocument],
    targetLanguage: machineTranslation.Language.CZECH
});

if (translationResults.errors.length) {
    // Handle the error message
    const docErrorId = translationResults.errors[0].documentId;
    const docErrorMessage = translationResults.errors[0].message;
}

...
// Add additional code 

          

Related Topics

General Notices