title: Mongoose error handling
body: <p>I'm attempting to do some validation for user input using Express and Mongoose. Previously, I had set a 'min-length' validator directly on the 'password' field of the User model. It would check that the inputted password string was long enough, and if it wasn't, it would be passed to the ValidationError object created when trying to save the User. This would be sent back to the user, and shown on the appropriate form field.</p>
  
  <p>But now that I've implemented hashing, salt, and encryption, this doesn't quite work properly. The hashed version of the password is much longer than the original password. So I thought I could do something like this:</p>
  
  <pre><code>exports.createNewUser = function(req, res, next){
  
      var user = new User({
              email : req.body.email
          , name : req.body.name
      })
      ,   minLength = Validator.minLength(req.body.password);
  
      if (!minLength) return next(new Error('Password aint right length'));
  
      user.setPassword(req.body.password);
  
      user.save(function(err){
          if (!err) return res.redirect('/');
          else {
              console.log('error saving usr', err);
              err['body'] = req.body;
              return res.render('user/register', err);
          }
      });
  };
  </code></pre>
  
  <p>The problem is that </p>
  
  <pre><code>return next(new Error('err message')); 
  </code></pre>
  
  <p>is simply shown on the console. I need some way of attaching it to the mongoose Validation Errors object. Any ideas?</p>