I have the following async function:
async function register() {
try {
if (password1 !== password2) {
throw "Passwords do not match!";
}
await firebase.auth().createUserWithEmailAndPassword(email, password1)
}
} catch (err) {
document.querySelector("#message").innerHTML = err;
return;
}
The first password match checks if the password entered by the user two times are identical. If they are, then use Firebase to create an account. But Firebase's createUserWithEmailAndPassword function return an error object that contains a error.code and a error.message. I only want to display the error.message and disregard the error.code. Is it possible to do it with the common catch block following the try, or I have to write a specific catch block for createUserWithEmailAndPassword to disregard the error code?