Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. PromiseRejectionEvent

PromiseRejectionEvent

Note: This feature is available inWeb Workers.

ThePromiseRejectionEvent interface represents events which are sent to the global script context when JavaScriptPromises are rejected. These events are particularly useful for telemetry and debugging purposes.

For details, seePromise rejection events.

Event PromiseRejectionEvent

Constructor

PromiseRejectionEvent()

Creates aPromiseRejectionEvent event, given the type of event (unhandledrejection orrejectionhandled) and other details.

Instance properties

Also inherits properties from its parentEvent.

PromiseRejectionEvent.promiseRead only

The JavaScriptPromise that was rejected.

PromiseRejectionEvent.reasonRead only

A value orObject indicating why the promise was rejected, as passed toPromise.reject().

Instance methods

This interface has no unique methods; inherits methods from its parentEvent.

Events

rejectionhandled

Fired when a JavaScriptPromise is rejected, and after the rejection is handled by the promise's rejection handling code.

unhandledrejection

Fired when a JavaScriptPromise is rejected but there is no rejection handler to deal with the rejection.

Examples

This simple example catches unhandled promise rejections and logs them for debugging purposes.

js
window.onunhandledrejection = (e) => {  console.log(e.reason);};

Specifications

Specification
HTML
# promiserejectionevent

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp