title: What's Mongoose error Cast to ObjectId failed for value XXX at path "_id"?
body: <p>When sending a request to <code>/customers/41224d776a326fb40f000001</code> and a document with <code>_id</code> <code>41224d776a326fb40f000001</code> does not exist, <code>doc</code> is <code>null</code> and I'm returning a <code>404</code>:</p>
  
  <pre><code>  Controller.prototype.show = function(id, res) {
      this.model.findById(id, function(err, doc) {
        if (err) {
          throw err;
        }
        if (!doc) {
          res.send(404);
        }
        return res.send(doc);
      });
    };
  </code></pre>
  
  <p>However, when <code>_id</code> does not match what Mongoose expects as "format" (I suppose) for example with <code>GET /customers/foo</code> a strange error is returned:</p>
  
  <blockquote>
    <p>CastError: Cast to ObjectId failed for value "foo" at path "_id".</p>
  </blockquote>
  
  <p>So what's this error?</p>