title: Javascript forEach swallowing exceptions
body: <p>I am trying to loop over an array using <code>forEach</code> loop with <code>async</code> callback in javascript. The problem is that when I throw an exception it gives </p>
  
  <pre><code>(node:2500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
  </code></pre>
  
  <p>Although I have a catch block after <code>forEach</code>. Here is my code</p>
  
  <pre><code>async function func() {
      try {
          array.forEach(async (e) =&gt; {
              try {
                  let bom = await BOMChild.findOne({
                      where: { id: e.id },
                  });
  
                  if (bom.BOMProductId || bom.BOMProductId === 0) {
                      throw {
                          name: " error",
                          description: `Description `,
                      };
                  }
              } catch (e) {
                  throw e;
              }
          });
      } catch (e) {
          //exception caught
      }
  }
  </code></pre>
  
  <p>What I am doing wrong and what is the possible way to solve this.
  TIA</p>