0

I am wrapping a collection of saves in a Ember.RSVP.all aggregator promise and the failure callback is not firing when an individual failure triggers. I have also tried Ember.RSVP.allSettled.

I am using ember-data's active model adapter plugin and my backend is returning 422 Not Processable which should trigger the failure callback.

var blueprintSavePromises = blueprints.map(function(bp){
  return bp.save().then(function(){
    console.log("individual save was successful");
  }, function(){
    console.log("individual save failed");
  });
});

var allBlueprintPromises = Ember.RSVP.allSettled(blueprintSavePromises);
allBlueprintPromises.then(function(){
  console.log("collection was successful");
}).catch(function(){
  console.log("collection was not successful");
});


// PUT http://test/test 422 (Unprocessable Entity)
// jquery.js:9659 XHR finished loading: PUT ...
// test-file.js:94 individual save failed
// test-file.js:110 collection was successful

What am I doing wrong?

xrl
  • 2,155
  • 5
  • 26
  • 40
  • Well, `allSettled` never fails… – Bergi Apr 23 '15 at 21:48
  • The log would make more sense if that first error message was `"individual failed save got handled"` (because that's what happened) – Bergi Apr 23 '15 at 21:51
  • Great, that was correct. I was not rethrowing the error so the promise chain was going back to the "success" path. Thanks! – xrl Apr 23 '15 at 23:56

0 Answers0