You need to understand that handling a rejection results in putting the promise back on the success path. One approach to this is to re-throw in the failure handler, like this:
var promises = [Promise.resolve("a"), Promise.reject("b")];
Promise.all(promises.map(function(p, index) {
return p.then(function(data) {
console.log("inside .map()", data, "index", index)
return data
}, function(err) {
console.log(err);
// RE-THROW!!
throw err;
})
}))
.then(...
If the purpose of the rejection handler is merely to log, then you could move it out of the chain:
Promise.all(promises.map(function(p, index) {
// MOVE ERROR HANDLER OUTSIDE OF CHAIN
p.catch(function(e) { console.log(e); });
return p.then(function(data) {
console.log("inside .map()", data, "index", index)
return data
})
}))
.then(...