3 回答
TA贡献1946条经验 获得超3个赞
promise1 rejected promise2 rejected promise3 rejected
promise.then(function(first_value) { console.log('promise1 resolved'); var promise = db.put(first_value); promise.then(function (second_value) { console.log('promise2 resolved'); var promise = db.put(second_value); promise.then( function (wins) { console.log('promise3 resolved'); }, function (err) { console.log('promise3 rejected'); return err; }); }, function (err) { console.log('promise2 rejected'); return err;});}, function (err) { console.log('promise1 rejected'); return err});
promise1 rejected
3 x rejected
1 x rejected, 2 x resolved
throw
deferred.reject(new Error())
throw new Error()
function (err) { console.log('promise1 rejected'); throw err; });
deferred.resolve(new Error())
deferred.reject(new Error())
deferred.reject(notAnError)
then
throw
始终用错误实例拒绝您的承诺(遵循同步世界的规则,其中抛出不是错误的值被认为是错误的做法)。 从同步回调中拒绝 投掷
错误(返回错误不能保证拒绝)。
添加回答
举报