Nodejs Promise() error swallowing
<p>I am struggling with promises</p>

<p>having the following snippet:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>Promise.resolve()
    .then(a("OK1"))
    .then(a("OK2"))
    .then(a("OK3"))
    .then(a("OK4"))
    .then(a("OK5"))
    .then(function() {
        console.log("FINISH");
    })
    .catch(function(e) {
      
        console.log("ERROR: " + e);
    });


function a(i) {
    return new Promise(function(resolve, reject) {
        
        if(i == "OK4") {
           console.log("THROW");
           throw('Error'); //This does not happen
           reject();
           return;
        }
        if(i == "OK2") {
          reject()
          return;
        }
        console.log(i);
        resolve();
    });
}</code></pre>
</div>
</div>
</p>

<p>i want to be able to reject a promise - then the next <code>.then</code> is executed ("OK3")
but i am unable to throw exceptions - i want to trigger the .catch on "OK4"</p>

<p>OK4 - is rejected and not outputted, but OK5 still gets executed - is there a way arround it?</p>

<p>this would be my expected output:</p>

<pre><code>OK1
OK3
ERROR: ....
</code></pre>