title: Multiple rejects from promises in Promise.all, what exactly happens?
body: <p><em>Promise.all([iterable])</em> is all or nothing, meaning that the promise it returns resolves when every promise in the iterable resolves, or rejects as soon as one of the promises rejects, with the reason of the first promise that rejects (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all" rel="nofollow noreferrer">doc</a>).</p>
  
  <p>But what happens if multiple promises of the <em>iterable</em> reject?</p>
  
  <p>In VSCode, I tried the following example, and purposely made both <em>foo()</em> and <em>bar()</em> promises fail. When I debug in VSCode I get an error on *        catch(err => Promise.reject('error query bar()'))* saying <strong>Exception has occurred</strong> and I don't understand why.</p>
  
  <p>I think it is because when I call Promise.reject the Promise.all has already received a reject from the foo function that also fails, but it is not clear what is happening.</p>
  
  <p>If I disable the "Uncaught Exceptions" breakpoint in the debugging options, the exception doesn't show up anymore.</p>
  
  <p><strong>What exactly is happening here?</strong></p>
  
  <pre><code>function foo() {
    return pool.query('insert_test into test (value) values (20)')
      .then(() =&gt; client.query('insert into test (value) values (21)'))
      .catch(err =&gt; Promise.reject('error query bar()'))
  }
  
  function bar() {
    return pool.query('insert_test into test (value) values (20)')
      .then(() =&gt; client.query('insert into test (value) values (21)'))
      .catch(err =&gt; Promise.reject('error query bar()'))
   }
  
   Promise.all([foo(), bar()])
     .then(results =&gt; {
       console.log(results)
     })
     .catch(err =&gt; {
       console.log(err)
     });
  </code></pre>
  
  <p>This is a screenshot of what I see with I have Uncaught Exceptions enabled.
  <a href="https://i.stack.imgur.com/xhTeW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xhTeW.png" alt="enter image description here"></a></p>