如果没有拒绝承诺连锁结果

mar*_*cel 2 javascript node.js promise angular-promise

我有一系列的承诺,我使用catch捕获错误.

this.load()
    .then(self.initialize)
    .then(self.close)
    .catch(function(error){
        //error-handling
    })
Run Code Online (Sandbox Code Playgroud)

如果链完成没有拒绝,会调用什么函数?我终于使用了,但是如果发生错误也会调用它.我想在catch函数之后调用一个函数,只有在没有承诺被拒绝的情况下才调用它.

我正在将node.js与q - 模块一起使用.

Man*_*nnu 5

添加另一个然后就可以了.

this.load()
    .then(self.initialize)
    .then(self.close)
    .then(function() {
      //Will be called if nothing is rejected
      //for sending response or so
    })
    .catch(function(error){
        //error-handling
    })
Run Code Online (Sandbox Code Playgroud)