So I have a base function that saves an Ember Data model, and runs common callback code on failure then returns the promise to the caller, so the caller can chain other callbacks on its own, but somehow, the chained callbacks from the caller are not executing as intended, the success code is being executed on failure and success, while the failure code is never executed
Here's the code for the common function:
// this function returns the model.save() promise to allow chaining of promises on the caller scope.
function baseCall() {
return model.save().then(function () {
//success
}, function (reason) {
//failure
if (reason.errors) {
model.set('errors', reason.errors);
}
});
}
And here's the caller code:
baseCall().then(function(post) {
console.log('super.success');//runs on failure AND success
}, function() {
console.log('super.failure');//never runs
});