This topic has not yet been rated - Rate this topic

Error object (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Provides specific information about an error that occurred during an asynchronous data operation.

Last modified: February 26, 2014

Introduced in Office.js version

1.0

Updated in Office.js version

1.1

asyncResult.error
Properties

Name

Description

code

Gets the numeric code of the error.

name

Gets the name of the error.

message

Gets a detailed description of the error.

The Error object is accessed from the AsyncResult object that is returned in the function passed as the callback argument of an asynchronous data operation, such as the setSelectedDataAsync method of the Document object.

Added support for content apps for Access.

The following example uses the setSelectedDataAsync method to set the selected text to "Hello World!", and if that fails, displays the values of the name and message properties of the Error object.

function setText() {

    Office.context.document.setSelectedDataAsync("Hello World!", {},
        function (asyncResult) {
            if (asyncResult.status === "failed")
            var err = asyncResult.error; 
                write(err.name + ": " + err.message);
        });
}

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

App types

Content apps, Mail apps, Task pane apps

Supported clients

Access app for SharePoint, Excel 2013, Excel 2013 SP1, Excel Online, Outlook 2013, Outlook 2013 SP1, Outlook Web App, OWA for Devices, PowerPoint 2013, PowerPoint 2013 SP1, Project 2013, Project 2013 SP1, Word 2013, and Word 2013 SP1

Library

Office.js

Namespace

Office

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.