14 lines
208 B
JavaScript

foo().then(
() => console.log("success"),
(error) => console.error(error.stack)
);
async function foo() {
await bar();
}
async function bar() {
await Promise.resolve();
throw new Error("Fail");
}