Have problem with error message display

Hi everyone, i have been struggling with handling the error messages, for example i want to be able to show the the user a message when the user is trying to re-register with an email address that is already in use, nothing seem to happen when the user click on the signup button , but when i tried to inspect on chrome console, i can see the error message that should display on my console but the user can see the message . please How do i resolve this?

example error message i want the user to see

 static async addUser(userInfo) {

    try {
      await users.insertOne({ 
         "name": userInfo.name,
         "email": userInfo.email,
         "password": userInfo.password,
        },
        { w: "majority" },
      )
      return { success: true }
    } catch (e) {
      if (String(e).startsWith("MongoError: E11000 duplicate key error")) {
        return { error: "A user with the given email already exists." }
      }
      console.error(`Error occurred while adding new user, ${e}.`)
      return { error: e }
    }
  }

another example of error messages i want the user to see

static async register(req, res) {
    try {
      const userFromBody = req.body
      let errors = {}
      if (userFromBody && userFromBody.password.length < 8) {
        errors.password = "Your password must be at least 8 characters."
      }
      if (userFromBody && userFromBody.name.length < 3) {
        errors.name = "You must specify a name of at least 3 characters."
      }

      if (Object.keys(errors).length > 0) {
        res.status(400).json(errors)
        return
      }

Hi @Clement_Ohiomoje_26072,

The course handouts/UI part has the functionality for showing the error message on console only. If someone needs to add UI elements, they can freely do in their handout.

Let me know if you have any questions.

Kanika