我试图弄清楚Node.js(v10.14.2)如何处理以下代码。特别是为什么在“异步10”之前显示控制台日志消息“抛出错误”?
const promise = Promise.resolve(10);
const process = async() => {
let val = await promise;
console.log('async ' + val);
};
const buggy = async() => {
throw new Error('Error thrown');
};
process();
buggy().catch(err => console.log(err.message));