连接并尝试显示我通过console.log获取此错误消息(错误)

{UserExistsError:具有给定用户名的用户已在Promise.resolve.then.then.then注册(/Users/rprater/Desktop/Hephaestus/EasyU/node_modules/passport-local-mongoose/index.js:238:17)名称:'UserExistsError',消息:'具有给定用户名的用户已注册'}

这是我用来获取它的代码,

router.post(“/ register”,function(req,res){

var firstName = titleize(req.body.firstName).trim();
    var lastName = titleize(req.body.lastName).trim();

    User.register(new User({
        firstName: firstName,
        lastName: lastName,
        username: req.body.username,
        university: req.body.university
      }), req.body.password, function(err, user){
        if(err){
            // console.log(err.message);
            req.flash("error", err.message);
            return res.render("registration");
        }
        //This will log the user in and store the correct information
        passport.authenticate("local")(req, res, function(){
            req.flash("success", "Welcome to EasyU" + " " + user.firstName);
            res.redirect("homePage");
        });
    });
});

请记住,所有其他类型的错误(例如未显示密码时)都会在网站上显示并显示 .

先谢谢你了 . :)