WindowEventHandlers.onunhandledrejection
The onunhandledrejection
property of the WindowEventHandlers
mixin is the event handler for processing unhandledrejection
events. These events are raised for unhandled Promise
rejections.
Syntax
window.onunhandledrejection = function;
Value
function
is an event handler or function to call when unhandledrejection
events are received by the window. The event handler receives as an input parameter as a PromiseRejectionEvent
.
Examples
This example logs unhandled rejections' reason
values to the console.
window.onunhandledrejection = function(e) { console.log(e.reason); }
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
onunhandledrejection |
49 |
79 |
69
68
55
This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 and enabled by default in Firefox 69.
|
No |
36 |
11 |
49 |
49 |
68
55
This event handler was added in Firefox 55 but was disabled since it wasn't fully implemented. It was fully implemented in Firefox 68 but not enabled by default.
|
No |
11.3 |
5.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunhandledrejection