I have developed an ionic2 app that utilizes firebase authentication. I am currently facing an issue when handling the "auth/account-exists-with-different-credential" error, specifically when a user tries to log in with the same email using multiple providers (such as Google and Facebook).
constructor(public af: AngularFire,public navCtrl: NavController) {
firebase.auth().getRedirectResult()
.then(res=>{
console.log('success',res)
})
.catch((err:any)=>{
console.log(error.message)
if (err.code=='auth/account-exists-with-different-credential'){
doaccountlink();
}
})
}
fblogin(){
firebase.auth().signInWithRedirect(new firebase.auth.FacebookAuthProvider())
}
gglogin(){
firebase.auth().signInWithRedirect(new firebase.auth.GoogleAuthProvider())
}
Although I am able to catch the error code in the catch block as expected, the problem arises when the exception continues to display in the console and on my page (as shown in the attached image). I am relatively new to JavaScript/TypeScript. In Java, if an error is already caught in the catch block, it should not continue to be displayed. Is there something wrong with my code? How can I prevent this exception from showing on my page?