How do I tell the difference between exceptions in flutter authenticating with Firebase? The Next CEO of Stack OverflowHow to remove the new firebase onAuthStateChanged listener in reactFirebase Authentication data mismatch between web and jvmHow to Signout a user in Flutter with Firebase authenticationGoogle Firebase Auth in Unity: How to read error codesWhy does Android Firebase skip authentication activitiesFlutter Firebase Authentication currentUser() returns nullFlutter Firebase signoutFlutter firebase handling exceptionsFlutter Firebase Authentication with External DatabaseFlutter App Freezes on Firebase Account Creation

Do scriptures give a method to recognize a truly self-realized person/jivanmukta?

Can this note be analyzed as a non-chord tone?

Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank

Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?

Help! I cannot understand this game’s notations!

Why is information "lost" when it got into a black hole?

Is it ok to trim down a tube patch?

Help/tips for a first time writer?

what's the use of '% to gdp' type of variables?

Audio Conversion With ADS1243

Is there an equivalent of cd - for cp or mv

Why don't programming languages automatically manage the synchronous/asynchronous problem?

It is correct to match light sources with the same color temperature?

Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens

how one can write a nice vector parser, something that does pgfvecparseA=B-C; D=E x F;

Can Sneak Attack be used when hitting with an improvised weapon?

Easy to read palindrome checker

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Where do students learn to solve polynomial equations these days?

What is the process for purifying your home if you believe it may have been previously used for pagan worship?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

Is dried pee considered dirt?

Won the lottery - how do I keep the money?



How do I tell the difference between exceptions in flutter authenticating with Firebase?



The Next CEO of Stack OverflowHow to remove the new firebase onAuthStateChanged listener in reactFirebase Authentication data mismatch between web and jvmHow to Signout a user in Flutter with Firebase authenticationGoogle Firebase Auth in Unity: How to read error codesWhy does Android Firebase skip authentication activitiesFlutter Firebase Authentication currentUser() returns nullFlutter Firebase signoutFlutter firebase handling exceptionsFlutter Firebase Authentication with External DatabaseFlutter App Freezes on Firebase Account Creation










1















I have Firebase a sign in for my app. I want to report exceptions to the user so he can correctly login. It is email and password sign in signInWithEmailAndPassword(_email, _password). Testing I can create two exceptions which are self explanatory



1/ Error: PlatformException(exception, There is no user record corresponding to this identifier. The user may have been deleted., null)



2/ Error: PlatformException(exception, The password is invalid or the user does not have a password., null)



I'm using a try catch block to catch the error. Here is my code:



void validateAndSubmit() async 
FocusScope.of(context).requestFocus(new FocusNode());
if (validateAndSave())
try
var auth = AuthProvider.of(context).auth;
FirebaseUser user =
await auth.signInWithEmailAndPassword(_email, _password);
print('Signed in: $user.uid');
Navigator.pop(context);
widget.loginCallback(user);

catch (e)
print('Error: $e');
setState(()
_showMessage=true;

);





I want to give a different message depending on the exception. But there doesn't seem to be any code associated with the exception.










share|improve this question




























    1















    I have Firebase a sign in for my app. I want to report exceptions to the user so he can correctly login. It is email and password sign in signInWithEmailAndPassword(_email, _password). Testing I can create two exceptions which are self explanatory



    1/ Error: PlatformException(exception, There is no user record corresponding to this identifier. The user may have been deleted., null)



    2/ Error: PlatformException(exception, The password is invalid or the user does not have a password., null)



    I'm using a try catch block to catch the error. Here is my code:



    void validateAndSubmit() async 
    FocusScope.of(context).requestFocus(new FocusNode());
    if (validateAndSave())
    try
    var auth = AuthProvider.of(context).auth;
    FirebaseUser user =
    await auth.signInWithEmailAndPassword(_email, _password);
    print('Signed in: $user.uid');
    Navigator.pop(context);
    widget.loginCallback(user);

    catch (e)
    print('Error: $e');
    setState(()
    _showMessage=true;

    );





    I want to give a different message depending on the exception. But there doesn't seem to be any code associated with the exception.










    share|improve this question


























      1












      1








      1








      I have Firebase a sign in for my app. I want to report exceptions to the user so he can correctly login. It is email and password sign in signInWithEmailAndPassword(_email, _password). Testing I can create two exceptions which are self explanatory



      1/ Error: PlatformException(exception, There is no user record corresponding to this identifier. The user may have been deleted., null)



      2/ Error: PlatformException(exception, The password is invalid or the user does not have a password., null)



      I'm using a try catch block to catch the error. Here is my code:



      void validateAndSubmit() async 
      FocusScope.of(context).requestFocus(new FocusNode());
      if (validateAndSave())
      try
      var auth = AuthProvider.of(context).auth;
      FirebaseUser user =
      await auth.signInWithEmailAndPassword(_email, _password);
      print('Signed in: $user.uid');
      Navigator.pop(context);
      widget.loginCallback(user);

      catch (e)
      print('Error: $e');
      setState(()
      _showMessage=true;

      );





      I want to give a different message depending on the exception. But there doesn't seem to be any code associated with the exception.










      share|improve this question
















      I have Firebase a sign in for my app. I want to report exceptions to the user so he can correctly login. It is email and password sign in signInWithEmailAndPassword(_email, _password). Testing I can create two exceptions which are self explanatory



      1/ Error: PlatformException(exception, There is no user record corresponding to this identifier. The user may have been deleted., null)



      2/ Error: PlatformException(exception, The password is invalid or the user does not have a password., null)



      I'm using a try catch block to catch the error. Here is my code:



      void validateAndSubmit() async 
      FocusScope.of(context).requestFocus(new FocusNode());
      if (validateAndSave())
      try
      var auth = AuthProvider.of(context).auth;
      FirebaseUser user =
      await auth.signInWithEmailAndPassword(_email, _password);
      print('Signed in: $user.uid');
      Navigator.pop(context);
      widget.loginCallback(user);

      catch (e)
      print('Error: $e');
      setState(()
      _showMessage=true;

      );





      I want to give a different message depending on the exception. But there doesn't seem to be any code associated with the exception.







      firebase dart flutter firebase-authentication






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 18:32







      flutter

















      asked Mar 7 at 18:30









      flutterflutter

      5373822




      5373822






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You can catch different kind of exceptions, for each exceptions, you can check the code




          void validateAndSubmit() async
          FocusScope.of(context).requestFocus(new FocusNode());
          if (validateAndSave())
          try
          var auth = AuthProvider.of(context).auth;
          FirebaseUser user =
          await auth.signInWithEmailAndPassword(_email, _password);
          print('Signed in: $user.uid');
          Navigator.pop(context);
          widget.loginCallback(user);

          on FirebaseAuthInvalidUserException catch (e)
          print('FirebaseAuthInvalidUserException: $e');
          if (e.code === 'ERROR_USER_NOT_FOUND')
          setState(()
          _showMessage=true;

          );
          else
          // do something


          on FirebaseAuthInvalidCredentialsException catch (e)
          // do something InvalidCredentials
          catch (e)
          // do something else







          share|improve this answer






























            0














            You can check e.code.
            Check out native firebase documentation. It has values like 'ERROR_USER_NOT_FOUND'






            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55050579%2fhow-do-i-tell-the-difference-between-exceptions-in-flutter-authenticating-with-f%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              You can catch different kind of exceptions, for each exceptions, you can check the code




              void validateAndSubmit() async
              FocusScope.of(context).requestFocus(new FocusNode());
              if (validateAndSave())
              try
              var auth = AuthProvider.of(context).auth;
              FirebaseUser user =
              await auth.signInWithEmailAndPassword(_email, _password);
              print('Signed in: $user.uid');
              Navigator.pop(context);
              widget.loginCallback(user);

              on FirebaseAuthInvalidUserException catch (e)
              print('FirebaseAuthInvalidUserException: $e');
              if (e.code === 'ERROR_USER_NOT_FOUND')
              setState(()
              _showMessage=true;

              );
              else
              // do something


              on FirebaseAuthInvalidCredentialsException catch (e)
              // do something InvalidCredentials
              catch (e)
              // do something else







              share|improve this answer



























                1














                You can catch different kind of exceptions, for each exceptions, you can check the code




                void validateAndSubmit() async
                FocusScope.of(context).requestFocus(new FocusNode());
                if (validateAndSave())
                try
                var auth = AuthProvider.of(context).auth;
                FirebaseUser user =
                await auth.signInWithEmailAndPassword(_email, _password);
                print('Signed in: $user.uid');
                Navigator.pop(context);
                widget.loginCallback(user);

                on FirebaseAuthInvalidUserException catch (e)
                print('FirebaseAuthInvalidUserException: $e');
                if (e.code === 'ERROR_USER_NOT_FOUND')
                setState(()
                _showMessage=true;

                );
                else
                // do something


                on FirebaseAuthInvalidCredentialsException catch (e)
                // do something InvalidCredentials
                catch (e)
                // do something else







                share|improve this answer

























                  1












                  1








                  1







                  You can catch different kind of exceptions, for each exceptions, you can check the code




                  void validateAndSubmit() async
                  FocusScope.of(context).requestFocus(new FocusNode());
                  if (validateAndSave())
                  try
                  var auth = AuthProvider.of(context).auth;
                  FirebaseUser user =
                  await auth.signInWithEmailAndPassword(_email, _password);
                  print('Signed in: $user.uid');
                  Navigator.pop(context);
                  widget.loginCallback(user);

                  on FirebaseAuthInvalidUserException catch (e)
                  print('FirebaseAuthInvalidUserException: $e');
                  if (e.code === 'ERROR_USER_NOT_FOUND')
                  setState(()
                  _showMessage=true;

                  );
                  else
                  // do something


                  on FirebaseAuthInvalidCredentialsException catch (e)
                  // do something InvalidCredentials
                  catch (e)
                  // do something else







                  share|improve this answer













                  You can catch different kind of exceptions, for each exceptions, you can check the code




                  void validateAndSubmit() async
                  FocusScope.of(context).requestFocus(new FocusNode());
                  if (validateAndSave())
                  try
                  var auth = AuthProvider.of(context).auth;
                  FirebaseUser user =
                  await auth.signInWithEmailAndPassword(_email, _password);
                  print('Signed in: $user.uid');
                  Navigator.pop(context);
                  widget.loginCallback(user);

                  on FirebaseAuthInvalidUserException catch (e)
                  print('FirebaseAuthInvalidUserException: $e');
                  if (e.code === 'ERROR_USER_NOT_FOUND')
                  setState(()
                  _showMessage=true;

                  );
                  else
                  // do something


                  on FirebaseAuthInvalidCredentialsException catch (e)
                  // do something InvalidCredentials
                  catch (e)
                  // do something else








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 8 at 4:11









                  TruongSinhTruongSinh

                  1,547823




                  1,547823























                      0














                      You can check e.code.
                      Check out native firebase documentation. It has values like 'ERROR_USER_NOT_FOUND'






                      share|improve this answer





























                        0














                        You can check e.code.
                        Check out native firebase documentation. It has values like 'ERROR_USER_NOT_FOUND'






                        share|improve this answer



























                          0












                          0








                          0







                          You can check e.code.
                          Check out native firebase documentation. It has values like 'ERROR_USER_NOT_FOUND'






                          share|improve this answer















                          You can check e.code.
                          Check out native firebase documentation. It has values like 'ERROR_USER_NOT_FOUND'







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 7 at 20:18

























                          answered Mar 7 at 20:12









                          nucleartuxnucleartux

                          74511034




                          74511034



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55050579%2fhow-do-i-tell-the-difference-between-exceptions-in-flutter-authenticating-with-f%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              1928 у кіно

                              Захаров Федір Захарович

                              Ель Греко