Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未捕获Firebase异常_Java_Android_Exception_Firebase_Firebase Authentication - Fatal编程技术网

Java 未捕获Firebase异常

Java 未捕获Firebase异常,java,android,exception,firebase,firebase-authentication,Java,Android,Exception,Firebase,Firebase Authentication,这是我现有的代码 mAuth.createUserWithEmailAndPassword(registration.getEmail(), registration.getPassword()) .addOnSuccessListener(this, authResult -> { Log.i("exception0", "here0"); })

这是我现有的代码

mAuth.createUserWithEmailAndPassword(registration.getEmail(), registration.getPassword())
                    .addOnSuccessListener(this, authResult -> {
                        Log.i("exception0", "here0");
                    })
                    .addOnFailureListener(this, exception -> {
                        if (exception instanceof FirebaseAuthWeakPasswordException) {
                            Log.i("exception1", "here");
                        } else if (exception instanceof FirebaseAuthInvalidCredentialsException) {
                            Log.i("exception2", "here1");
                        } else if (exception instanceof FirebaseAuthUserCollisionException) {
                            Log.i("exception3", "here2");
                        } else if (exception instanceof FirebaseAuthInvalidUserException) {
                            Log.i("exception4", "here3");
                        } else if (exception instanceof FirebaseAuthException) {
                            Log.i("exception5", "here4");
                        } else if (exception instanceof FirebaseException) {
                            FirebaseException firebaseException = (FirebaseException) exception;
                            Log.i("exception6", "here5" + firebaseException.getMessage());
                        } else {
                            Log.i("exception7", "here6");
                        }
                    });
我知道异常需要是弱密码异常,但捕获的异常是FirebaseException

我甚至尝试了以下代码

if(!task.isSuccessful()) {
try {
    throw task.getException();
} catch(FirebaseAuthWeakPasswordException e) {
    mTxtPassword.setError(getString(R.string.error_weak_password));
    mTxtPassword.requestFocus();
} catch(FirebaseAuthInvalidCredentialsException e) {
    mTxtEmail.setError(getString(R.string.error_invalid_email));
    mTxtEmail.requestFocus();
} catch(FirebaseAuthUserCollisionException e) {
    mTxtEmail.setError(getString(R.string.error_user_exists));
    mTxtEmail.requestFocus();
} catch(Exception e) {
    Log.e(TAG, e.getMessage());
}
}
但它总是捕获最后一个通用异常,而不是特定异常。

尝试以下操作:

if(e.getClass().equals(FirebaseAuthWeakPasswordException.class))

如果在
here5
分支中记录
exception.getClass().getName()
,会得到什么?