Ionic Facebook login has inadequate error handling please advise?

Hi All,

I am using Ionic2 with the Ionic native Facebook api in order to authenticate a user on Firebase.

loginFacebookCordova(): Promise<FirebaseAuthState> {
    return new Promise<FirebaseAuthState>((resolve) => {
        Facebook.login(['public_profile', 'email']).then(facebookData => {
            let cred: firebase.auth.AuthCredential = firebase.auth.FacebookAuthProvider.credential(facebookData.authResponse.accessToken);
            firebase.auth().signInWithCredential(cred).then((data: FirebaseAuthState) => {
                resolve(data);
            });
        }, error => {
            this.loading.dismiss();
            console.error('loginFacebook: ' + error);
            this.doAlert('Login with Facebook: ' + error.message);
        }).catch((error) => {
            this.loading.dismiss();
            console.error('loginFacebook: ' + error);
            this.doAlert('Login with Facebook: ' + error.message);
        });
    });
}

This works fine and I can create a registerd user on Firebase.

Problem

If I first create a user using GooglePlus (with the same email address), then log out. And try login with Facebook, then it just hangs, with no error message.

Question

How do I login to via Facebook, but get proper error handling or warning messages?

Apologies, the error was on my side. I was not catching the error correctly.

           firebase.auth().signInWithCredential(cred).then((data: FirebaseAuthState) => {
                resolve(data);
            }).catch((error) => {
                this.loading.dismiss();
                console.error('loginFacebook: ' + error);
                this.doAlert('Login with Facebook: ' + error.message);
            });