title: Knexjs and es6 Try/Catch causing an Unhandled Promise Rejection Warning?
body: <p>I've been working on a new application that uses PostgreSQL and Knexjs as a query builder, but have been running into an issue I'm not sure how to handle.</p>
  
  <p>I have a route handler that looks like so:</p>
  
  <pre><code>export const getSingleUser = async(req, res) =&gt; {
    let respObj = {
      status: 'fail',
      message: 'User does not exist'
    };
  
    try {
      const user = await knex('users').where('id', req.params.id).first();
      if (!user) {
        res.send(respObj);
      }
      respObj = {
        status: 'success',
        data: user
      };
      res.send(respObj);
    } catch(e) {
      res.send(respObj);
    }
  };
  </code></pre>
  
  <p>It works great, until I throw a non-existent user ID into the mix. I assumed the catch statement would handle the error if no user is found for the query, but that doesn't seem to work, it just spits out the <code>respObj</code> in the try block. So I added an if statement to check if the user object doesn't exist, and thats when I received the warning below:</p>
  
  <pre><code>(node:25711) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
      at validateHeader (_http_outgoing.js:503:11)
      at ServerResponse.setHeader (_http_outgoing.js:510:3)
      at ServerResponse.header (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/express/lib/response.js:767:10)
      at ServerResponse.send (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/express/lib/response.js:170:12)
      at ServerResponse.json (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/express/lib/response.js:267:15)
      at ServerResponse.send (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/express/lib/response.js:158:21)
      at _callee3$ (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/src/controllers/userController.js:45:7)
      at tryCatch (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/regenerator-runtime/runtime.js:65:40)
      at Generator.invoke [as _invoke] (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/regenerator-runtime/runtime.js:303:22)
      at Generator.prototype.(anonymous function) [as next] (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/node_modules/regenerator-runtime/runtime.js:117:21)
      at step (/Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/src/controllers/userController.js:14:191)
      at /Users/munsterberg/Sites/fullstack_workspace/esports-manager/services/project/src/controllers/userController.js:14:361
      at &lt;anonymous&gt;
  (node:25711) 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)
  (node:25711) [DEP0018] 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></pre>
  
  <p>Can anyone provide more info on why this is happening, and whats the fix?</p>