PromiseRejectionEvent: reason property
Note: This feature is available in Web Workers.
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
Specification |
---|
HTML # dom-promiserejectionevent-reason |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reason |
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.