Promise.onerror event

Applies to Windows and Windows Phone

Occurs when there is an error in processing a promise.

The onerror event occurs whenever a runtime error is caught in any promise, whether or not it is handled elsewhere. You can use the error handler to set breakpoints while you're debugging or to provide general error handling such as error logging. But because this is a general error handling mechanism, you might not get much detail about the exact code or user input that caused the error.

For more information, see How to handle errors with promises.

Syntax


promise.addEventListener("error", listener);
//or 
promise.onerror = listener;

Event information

SynchronousNo
BubblesYes
CancelableYes

 

Event handler parameters

eventInfo

Type: CustomEvent

An object that contains information about the event.

Remarks

Here's how to add a general error handler:


function activatedHandler() {
    // add general activation code.
    WinJS.Promise.onerror = errorHandler;
}
function errorhandler(event) {
        // add general error handling, for example:
        var ex = event.detail.exception;
        var promise = event.detail.promise;
    }


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS

Library

Base.js

See also

Promise

 

 

Show:
© 2014 Microsoft