Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get more information from firebase error?

I have this error from firebase that says :

An internal error has occured, print and inspect the error details from more information.

How can I know what the error is??,

here is my code for printing the error

 let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
    FIRAuth.auth()?.signInWithCredential(credential, completion: {(user, error) in
        if error != nil {
            SCLAlertView().showError("error #1", subTitle: (error?.localizedDescription)!)
            return
        }
})
like image 732
slimboy Avatar asked Dec 07 '25 06:12

slimboy


1 Answers

You can convert error from Error to NSError, then get the error code. So you will be able to get the FIRAuthErrorCode.

for example:

let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
    FIRAuth.auth()?.signIn(with: credential, completion: {(user, error) in
        if error != nil {
            let castedError = error! as NSError
            let firebaseError = FIRAuthErrorCode(rawValue: castedError.code)
            if firebaseError != nil {
                switch(firebaseError!) {
                case .errorCodeWrongPassword:
                    //do something or break
                    break
                default:
                    //do something or break
                    break
                }
            }
        }
    })

Check all possible errors in FIRAuthErrorCode here

like image 90
Eduardo Tolmasquim Avatar answered Dec 08 '25 19:12

Eduardo Tolmasquim