Already Existing Member & email check - Custom member registration

Hi… I’m trying to make a custom member registration, But i can’t understand how to add a simple error message that check and show if the name and the email already exist in the members/database. This is my registration page code:

import wixData from'wix-data';
import wixUsers from'wix-users';

$w.onReady(function () {

$w('#submitButton').onClick( (event) => {    // submit button
let email = $w('#emailInput').value;   // email input
let password = $w('#passwordInput').value;   // password input

// the (below) code registers the user
  wixUsers.register(email, password)
  .then( (result) => {
 
let user = wixUsers.currentUser;
let userId1 = user.id;
 
 // the (below) code ,after registration, inserts the name, class, userId  etc to database.
 
 let toInsert = {
 "name":    $w('#nameInput').value,   // id of the field where the name of students or parents store and name input.
 
 "class":   $w('#istitutoInput').value,   //id of the field where the class of students store and class input.
 
 "userId":   userId1 
};
wixData.insert("Utenti", toInsert)  // Database name
  .then( (results) => {
  console.log("User registered");
});
 
});
});

});

Please help me, thank you!