【发布时间】:2021-11-15 20:34:18
【问题描述】:
这只是我的代码的示例代码
async function thisThrows() {
throw new Error("Thrown from thisThrows()");
}
async function run() {
try {
await thisThrows();
} catch (e) {
throw new Error(e)
}
}
async function run1() {
try{
await run()
}catch(e){
throw new Error(e);
}
}
run1().catch(error => {
console.log(error);
});
下面的代码 sn-p 给了我嵌套的错误输出 即错误:错误:错误
Error: Error: Error: Thrown from thisThrows()
at run1 (/Users/saunish/servify/sandbox/error-handling.js:18:15)
我需要输出是
Error: Thrown from thisThrows()
【问题讨论】:
标签: node.js error-handling async-await promise try-catch