title: How to throw exception from async function
body: <p>I have an async function that I expect to throw exception on failure. However something seems to preventing this:</p>
  
  <p>by omitting the try catch blocks I expect an exception to be thrown which I want to handle outside of the function.</p>
  
  <p>The actual result I get is somewhat confusing: </p>
  
  <p><code>(node:10636) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): E11000 duplicate key error index.</code></p>
  
  <p><code>(node:10636) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</code></p>
  
  <pre><code>async f(obj) {
      await db.collection('...').save(obj);
  }
  </code></pre>
  
  <p>I get the same result when I try to catch the exception and throw something else instead:</p>
  
  <pre><code>async f(obj) {
      try {
          await db.collection('...').save(obj);
      } catch(e) {
          throw e.message;
      }
  }
  </code></pre>
  
  <p>The function is called from a try block, so don't see how this is an Unhandled Promise.</p>
  
  <p>I am trying to use <code>f</code> as a parameter of another function:</p>
  
  <pre><code>g(obj, handler) {
      try {
          handler(obj);
      } catch(e);
          ...
      }
  }
  
  g(objToSave, f);
  </code></pre>