The PromiseRejectionEvent()
constructor returns a new PromiseRejectionEvent
object, which represents events fired when a JavaScript Promise
is rejected.
With promise rejection events, it becomes possible to detect and report promises which fail and whose failures go unnoticed. It also becomes easier to write a global handler for errors.
There are two types of PromiseRejectionEvent
: unhandledrejection
is sent by the JavaScript runtime when a promise is rejected but the rejection goes unhandled. A rejectionhandled
event is emitted if a promise is rejected but the rejection is caught by a rejection handler.