2024-08-29 00:56:15 +01:00
|
|
|
globalThis.addEventListener("unhandledrejection", (event) => {
|
2024-01-12 23:10:42 +01:00
|
|
|
console.log("unhandledrejection", event.reason, event.promise);
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
|
2024-08-29 00:56:15 +01:00
|
|
|
globalThis.addEventListener("rejectionhandled", (event) => {
|
2024-01-12 23:10:42 +01:00
|
|
|
console.log("rejectionhandled", event.reason, event.promise);
|
|
|
|
});
|
|
|
|
|
|
|
|
const a = Promise.reject(1);
|
|
|
|
setTimeout(async () => {
|
|
|
|
a.catch(() => console.log("Added catch handler to the promise"));
|
|
|
|
}, 10);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log("Success");
|
2024-04-19 00:40:15 +01:00
|
|
|
}, 1000);
|