问题得到妥善承诺失败后function运行失效

我试图拒绝一个承诺,似乎在工作,但并不像预期的那样。

Parse.Promise.as(1).then(function() { var vendor = user.get('vendor'); if (vendor) return vendor.fetch(); else return Parse.Promise.error("No vendor found"); }, function() { //specific promise error for this particular promise res.redirect('/vendor/signup'); }).then(function(result) { var vendor = result; res.render('vendor/dashboard.ejs', { 'user': user, 'vendor': vendor }); }).fail(function(error) { //general catch all error controller res.render('error.ejs', { 'error': error }); }); 

如果承诺失败的第一部分,它试图加载供应商,我想错误的redirect。 相反,它正在下降到结局失败。 什么是正确的方法来做到这一点? 如果它存在的话,那么第二个函数是不是传递给它的呢?

.then(onFulfilled,onRejected)的基本签名是.then(onFulfilled,onRejected) – 这意味着它承诺它被调用并根据该承诺的parsing来调用处理程序:

  p.then(function onFulfilled(){ // this gets called only when p fulfills. },function(){ // this gets called only when p is rejected, if the above onFulfilled // rejects, this doesn't get called, instead it'll propagate }); 

一般来说,附加一个.then(null,function(){处理程序到手; e代码段中的exception:

  p.then(function onFulfilled(){ // this gets called only when p fulfills. }).then(null,function(){ // <- note the .then // this gets called only when the above promise _including_ the onFulfilled // handler rejects. Since now the code is `.then`ing the result of the promise // created by the first .then handler. }); 

另外 – 使用库中的.catch支持清晰,不幸的是,这不是parse.com的承诺。