How to catch error in asynchronous Proxy/Reflect trap
<p>How do I catch an error that gets thrown asynchronously by <code>Reflect.get(target, name, receiver)</code> within the Proxy handler?</p>

<p>I'm using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="nofollow">Proxy</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect" rel="nofollow">Reflect</a> to wrap an <strong>API</strong> class, so that I can catch any Network exceptions and gracefully display error messages to the user.</p>

<pre class="lang-js prettyprint-override">
//Wrapper.js

let handler = {
  get: (target, name, receiver) => {
    try {
      Reflect.get(target, name, receiver); //throws Error asynchronously
    } catch (e) {
      console.log('caught error', e);
    }
};

export default new Proxy(new API(), handler);
</pre>

<pre class="lang-js prettyprint-override">
//App.js

import Wrapper from './Wrapper';

Wrapper.asyncFunction(); //throws uncaught Error
</pre>

<pre class="lang-js prettyprint-override">
//API.js

class API {
  get user() {
    return new User()
  }
}
</pre>

<pre class="lang-js prettyprint-override">
//User.js

class User {

  /**
   * List all users
   */
  all() {
    return new Promise((resolve, reject) => {
      reject(new Error('Network error'));
    });
  }
}
</pre>

<p>When an error is thrown, inside Reflect.get() "caught error" never gets printed and remains uncaught.</p>