HTML DOM
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
window.onunhandledrejection = (e) => {
console.log(e.reason);
};
Specifications
Browser compatibility
See also
- Promise
- PromiseRejectionEvent
- Window.rejectionhandled_event
- Window.unhandledrejection_event
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
