I am trying to break out of the promise chain, but even after the reject('something')
all the then(methods)
are getting executed and finally the catch()
. Shouldn't it directly execute the catch
skipping the then(methods)
.
method1()
.then(method2())
.then(method3())
.then(method4())
.then(method5())
.catch(errohandler())
method1(){
return new Promise(function (resolve, reject) {
if (some condition) {
reject(new Error("error"));
} else {
resolve("correct entity. all parameters present");
}
});
}
The control goes to the if block as my condition is true and also the error message is getting displayed in catch block later. However all the then(methods) are getting executed.