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
| Synchronous | No |
|---|---|
| Bubbles | Yes |
| Cancelable | Yes |
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 |
|
See also
Build date: 12/5/2012