How to catch a Firebase Auth specific exceptions

前端 未结 16 2318
慢半拍i
慢半拍i 2020-11-28 04:37

Using Firebase, how do I catch a specific exception and tell the user gracefully about it? E.g :

FirebaseAuthInvalidCredentialsException: The email ad

16条回答
  •  难免孤独
    2020-11-28 05:08

        try {
                throw task.getException();
            } catch(FirebaseAuthException e) {
               switch (e.getErrorCode()){
                            case "ERROR_WEAK_PASSWORD":
                          Toast.makeText(this, "The given password is invalid.", Toast.LENGTH_SHORT).show();
                                 break;
                          //and other
                        }
            }
    

    error codes: https://stackoverflow.com/a/38244409/2425851

提交回复
热议问题