1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 18:17:48 -05:00
denoland-deno/tests/specs/run/rejection_handled/rejection_handled.ts
2024-11-05 06:39:05 +00:00

17 lines
476 B
TypeScript

globalThis.addEventListener("unhandledrejection", (event) => {
console.log("unhandledrejection", event.reason, event.promise);
event.preventDefault();
});
globalThis.addEventListener("rejectionhandled", (event) => {
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");
}, 1000);