Skip to content

PromiseRejectionEvent ​

PromiseRejectionEvent represents a Promise rejection that wasn't handled. It is the event object of the unhandledrejection event on application, carrying the rejection reason and the rejected Promise.

Inheritance: Event → PromiseRejectionEvent

Constructor ​

PromiseRejectionEvent()

Creates a rejection event object. The runtime creates it itself when firing unhandledrejection; app code generally doesn't need it.

Instance properties ​

Also inherits properties from Event. For the unhandledrejection event fired by the runtime, cancelable is true.

PropertyDescription
reason read-onlyThe rejection reason
promise read-onlyThe Promise that was rejected

Examples ​

js
application.addEventListener('unhandledrejection', (e) => {
  console.log(e instanceof PromiseRejectionEvent, String(e.reason));
  e.preventDefault();
});
Promise.reject(new Error('Nobody caught this'));

Result: Prints true Error: Nobody caught this.

Comparison with the browser ​

BrowserNacre
rejectionhandled eventNone

See also ​