Promise错误处理两种方法
第二种方法不行,老师讲的有错,你运行下我下面的代码,throw 出来的错误没有被catch捕获到:
console.log('here we go');new Promise((resolve)=>{	setTimeout(()=>{		throw new Error('bye');	},2000);}).then((value)=>{	console.log(val + 'world');}).catch((error)=>{	console.log('Error---------------', error.message);});throw new error('错误信息),
.catch(function(error){
console.log("Error:",error.message)
})