Office.Error interface

Предоставляет конкретные сведения об ошибке, возникшей во время выполнения асинхронной операции с данными.

Комментарии

Доступ к объекту Error осуществляется из объекта AsyncResult, возвращаемого в функции, переданной в качестве аргумента обратного вызова асинхронной операции данных, например setSelectedDataAsync метода объекта Document.

Свойства

code

Получает цифровой код ошибки. Список кодов ошибок см. в разделе Коды ошибок API JavaScript для Office.

message

Получает подробное описание ошибки.

name

Получает имя ошибки.

Сведения о свойстве

code

Получает цифровой код ошибки. Список кодов ошибок см. в разделе Коды ошибок API JavaScript для Office.

code: number;

Значение свойства

number

Примеры

// To cause an error to be thrown, select a table or a matrix, and then call the setText function.
function setText() {
    Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            if (asyncResult.status === "failed")
                const error = asyncResult.error;
            write(error.name + ": " + error.code + " - " + error.message);
        });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

message

Получает подробное описание ошибки.

message: string;

Значение свойства

string

Примеры

// To cause an error to be thrown, select a table or a matrix, and then call the setText function.
function setText() {
    Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            if (asyncResult.status === "failed")
                const error = asyncResult.error;
            write(error.name + ": " + error.message);
        });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

name

Получает имя ошибки.

name: string;

Значение свойства

string

Примеры

// To cause an error to be thrown, select a table or a matrix, and then call the setText function.
function setText() {
    Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            if (asyncResult.status === "failed")
                const error = asyncResult.error;
            write(error.name + ": " + error.message);
        });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}