Promise.onerror event

4 out of 6 rated this helpful - Rate this topic

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


WinJS.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]

Namespace

WinJS

Library

Base.js

See also

Promise

 

 

Build date: 12/5/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.