Reading Firebase Auth Error Thrown (Firebase 3.x and Swift)

Try this. This works for me. Also, after pasting this into your project. If you need to see all the FIRAuthErrorCode codes. Hover your mouse over .ErrorCodeInvalidEmail then press your left mouse button and it will show you the rest.

If you have any problems let me know and ill try to help you. Good luck!

        FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in

            if error != nil {

                if let errCode = FIRAuthErrorCode(rawValue: error!._code) {

                    switch errCode {
                        case .ErrorCodeInvalidEmail:
                            print("invalid email")
                        case .ErrorCodeEmailAlreadyInUse:
                            print("in use")
                        default:
                            print("Create User Error: \(error!)")
                    }
                }

            } else {
                print("all good... continue")
            }
        }

None of answers seem to be up-to-date, here's what I do currently on Swift 3.x, FirebaseAuth 4.0.0

Auth.auth().signIn(withEmail: email, password: password) { (user, error) in

        if let error = error as NSError? {

            guard let errorCode = AuthErrorCode(rawValue: error.code) else {

                print("there was an error logging in but it could not be matched with a firebase code")
                return

            }

            switch errorCode {

            case .invalidEmail:

                print("invalid email")

                //...