PromiseRejectionEvent: reason property

The PromiseRejectionEvent reason read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). This in theory provides information about why the promise was rejected.

Value

A value or object which provides information you can use to understand why the promise was rejected. This could be anything from an error code to an object with text, links, and whatever else you might wish to include.

Examples

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android
reason 49 79 69 36 11 49 79 36 11.3 5.0 49

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent/reason