reject 和 catch 的处理上

1
2
3
4
5
6
auto.getData().then(function (results) {
res.send(results);
}, next);
auto.getData().then(function (results) {
res.send(results);
}).catch(next);
第一种写法,next函数只会处理getData中的reject时的异常情况。



第二种写法,catch会捕捉到在它之前的promise链上的代码抛出的异常,不仅仅是getData,还有then()里面的异常。


---

好吧看到了就整理搬运过来了,免得到时候找不到了 orz