私は約束を解消しようとしていますが、reject('something')
の後もすべてthen(methods)
が実行され、最後にcatch()
となっています。直接catch
を実行して、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");
}
});
}
私の条件が真で、エラーメッセージが後でキャッチブロックに表示されるため、コントロールはifブロックに移動します。しかし、すべての(メソッド)が実行されています。
私は思います問題はあなたがmethod2()を呼び出して... mehod2を関数として入れないことです。 – Alon