summaryrefslogtreecommitdiff
path: root/tests/testdata/run/rejection_handled.ts
blob: 8822203f1482c8318b2364b02a14bb01baa9be50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);