Office.Error interface

非同期的なデータ操作中に発生したエラーに関する特定の情報を提供します。

注釈

Error オブジェクトは、Document オブジェクトのメソッドなど setSelectedDataAsync 、非同期データ操作のコールバック引数として渡される関数で返される AsyncResult オブジェクトからアクセスされます。

プロパティ

code

エラーの数値コードを取得します。 エラー コードの一覧については、「 JavaScript API for Office のエラー コード」を参照してください。

message

エラーの詳細な説明を取得します。

name

エラーの名前を取得します。

プロパティの詳細

code

エラーの数値コードを取得します。 エラー コードの一覧については、「 JavaScript API for 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; 
}