Nos bénévoles n'ont pas encore traduit cet article en Français. Inscrivez-vous et aidez-nous à réaliser cette tâche !
Vous pouvez également lire cet article en English (US).

The rejectionhandled event is sent to the script's global scope (usually window but also Worker) whenever a JavaScript Promise is rejected but after the promise rejection has been handled. This can be used in debugging and for general application resiliency, in tandem with the unhandledrejection event, which is sent when a promise is rejected but there is no hander for the rejection.

Bubbles No
Cancelable No
Interface PromiseRejectionEvent
Event handler property onrejectionhandled

Example

You can use the rejectionhandled event to log promises that get rejected to the console, along with the reasons why they were rejected:

window.addEventListener("rejectionhandled", event => {
  console.log("Promise rejected; reason: " + event.reason);
}, false);

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'rejectionhandled' in that specification.
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
rejectionhandled eventChrome Full support 49Edge ? Firefox No support No
Notes
No support No
Notes
Notes Firefox implements the PromiseRejectionEvent interface if you go to about:config and set the dom.promise_rejection_events.enabled pref to true. However, Firefox doesn't yet actually send the unhandledrejection or understand rejectionhandled events. Completing the implementation will be addressed in bug 1362272.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android No support No
Notes
No support No
Notes
Notes Firefox implements the PromiseRejectionEvent interface if you go to about:config and set the dom.promise_rejection_events.enabled pref to true. However, Firefox doesn't yet actually send the unhandledrejection or understand rejectionhandled events. Completing the implementation will be addressed in bug 1362272.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Étiquettes et contributeurs liés au document

Dernière mise à jour par : Laoujin,