I would like to catch all unhandled exceptions/rejections that take place within a javascript Promise. Is there a good method for catching them without adding a .catch
The whole world is waiting for the unhandledrejection
and rejectionhandled
events. As of March 2016, Chrome is now the first to support it.
Example:
window.addEventListener('unhandledrejection', function(event) {
console.error('Unhandled rejection (promise: ', event.promise, ', reason: ', event.reason, ').');
});
Specification: HTML Living Standard
Mozilla Developer: onrejectionhandled, onunhandledrejection
Chromium Issues: 495801, 393913