<p>コンソールをご覧ください</p>
// 50%の確率でエラー
const function1 = () => {
try {
if (Math.random() > 0.5) {
foo.bar;
}
} catch (error) {
throw new Error("fooが存在しないですよ😡", {
cause: error
});
}
};
// 50%の確率でエラー
const function2 = () => {
try {
if (Math.random() > 0.5) {
baz.qux;
}
} catch (error) {
throw new Error("bazが存在しないですよ🤯", {
cause: error
});
}
};
// function1とfunction2を実行する
try {
function1();
function2();
console.log("成功です!");
} catch (error) {
console.log(error);
console.log(error.cause);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.