Could someone explain to me why returning promises in promises callbacks is considered antipattern? Apparently it breaks exception bubbling but obviously my understanding of promises is lacking as I cannot clearly picture how would that work. My antipattern code is below:
var a = new Promise(function (res, rej) {
setTimeout(function () {
res("timeout");
}, 1000);
});
a.then(function (res) {
console.log("a");
console.log(res);
return new Promise(function (res, rej) {
console.log("b");
setTimeout(function () {
res("timeout2");
}, 2000);
}).then(function (res) {
console.log("c");
console.log(res);
}).then(function (res) {
console.log("d");
console.log(res);
}, function (res) {
console.log("e");
console.log(res);
});
}).then(function (res) {
console.log("l");
console.log(res);
});
EDIT:
This question is related to one of my previous questions where I do something similar with promises and one of the answers says:
"You must also never mix callbacks with promises because then you lose exception bubbling (the point of promises) and make your code super verbose."
So now I'm really confused if it is antipattern and if so why.