Window: rejectionhandled イベント
rejectionhandled
イベントは、 JavaScript の Promise
が拒否されたものの、その後で Promise の拒否が処理された場合にスクリプトのグローバルスコープ (ふつうは window
だが Worker
の場合もある) に送られます。これは、 Promise が拒否されたが拒否の手助けがないときに送信される unhandledrejection
イベントと並行して、デバッグや一般的なアプリケーションの回復に使用できます。
バブリング | なし |
---|---|
キャンセル可能 | いいえ |
インターフェイス | PromiseRejectionEvent |
イベントハンドラープロパティ |
onrejectionhandled
|
例
rejectionhandled
イベントを使用して、拒否された Promise を、拒否された理由を添えてコンソールに出力することができます。
js
window.addEventListener(
"rejectionhandled",
(event) => {
console.log("Promise rejected; reason: " + event.reason);
},
false,
);
仕様書
Specification |
---|
HTML # unhandled-promise-rejections |
HTML # handler-window-onrejectionhandled |
ブラウザーの対応
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rejectionhandled event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.