title: Proper error handling in mongoose query.exec()
body: <p>I've digged into Mongoose docs, but I still can't find the information how I should handle errors in <code>query.exec()</code>.</p>
  
  <pre><code>var query = User.findOne({_id: userId});
  
      var promise = query.exec(function(err) {
          if (err) {
              res.json(err);
              return;
          }
      });
      promise.then(function(user) {
          res.json(user.name);
      });
  </code></pre>
  
  <p>When I pass incorrect userId, I'm getting <code>Unhandled rejection CastError: Cast to ObjectId failed</code> error printed to the console.</p>
  
  <p>I thought that <code>res.json(err)</code> followed by <code>return</code> statement will be enough to handle the error correctly and prevent it from being shown in the console, but it's not. What should I do instead?</p>