The Window.onunhandledrejection
property is an event handler for processing unhandledrejection
events, which are raised for unhandled Promise
rejections.
Syntax
window.addEventListener("unhandledrejection", function(event) { ... }); window.onunhandledrejection = function(event) { ...};
The event received by the event handler is a PromiseRejectionEvent
.
Examples
window.onunhandledrejection = function(e) { console.log(e.reason); }
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'onunhandledrejection' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 49 | No support[1] | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | No support | No support[1] | No support | No support | No support |
[1] In Firefox, this is implemented but disabled by default. To turn it on, go to about:config and set the dom.promise_rejection_events.enabled
pref to true
.