title: How to deal with error object passed into callback in an async remote method?
body: <p>I want my remote method <strong>returns a 404 HTTP error</strong> created by <code>http-errors</code> with the message in a remote method implemented in an async way like below.</p>
  
  <pre><code>const createError = require('http-errors');
  
  Model.methodA = async (postBody, cb) =&gt; {
    const resp = await fetchData()
    if(!resp){
      return cb(createError(404, `data not found`));
    }
    return resp;
  }
  
  Model.remoteMethod(
    'methodA',
    {
      description: '',
      http: {path: '/', verb: 'post', status: 200},
      accepts: [
        {
          arg: 'postBody',
          type: 'object',
          http: {source: 'body'}
        }
      ],
      returns: {type: 'object', root: true}
    });
  </code></pre>
  
  <p>However, when I ran the code above, it always says I'm not dealing with promise rejection correctly.</p>
  
  <pre><code>(node:39109) 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: 1)
  </code></pre>
  
  <p>I know I can change the way I call <code>fetchData()</code> into <code>fetchData().then().catch()</code>, and then no need to decorate my <code>methodA</code> with <code>async</code> keyword. I still think there gotta be a better way to deal with this async methodA calling though. Thanks.</p>