title: How to handle error when MongoDB collection is updating in JavaScript(Node.js)
body: <p>I've been trying get an error when running bad code. The following code tries to update a record which has <code>_id</code> value 5. There is actually no such record, but I can't catch any error messages with the following function. </p>
  
  <p>What should I do?</p>
  
  <pre><code>collection.update(
      { _id : "5" }, 
      // { _id : req.session.User._id }, 
      { $set: { password : req.param('password') } }, 
      { writeConcern: { w: "majority", wtimeout: 3000 } },
      function(err, result) {
          if (err) { console.log(err); return err; }
  
          res.send("/user/show");
      }
  );
  </code></pre>