mirror of
https://github.com/denoland/deno.git
synced 2024-12-29 10:39:10 -05:00
7471587d29
This commit adds support for "rejectionhandled" Web Event and "rejectionHandled" Node event. ```js import process from "node:process"; process.on("rejectionHandled", (promise) => { console.log("rejectionHandled", reason, promise); }); window.addEventListener("rejectionhandled", (event) => { console.log("rejectionhandled", event.reason, event.promise); }); ``` --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
17 lines
466 B
TypeScript
17 lines
466 B
TypeScript
window.addEventListener("unhandledrejection", (event) => {
|
|
console.log("unhandledrejection", event.reason, event.promise);
|
|
event.preventDefault();
|
|
});
|
|
|
|
window.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");
|
|
}, 50);
|