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

                              Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                              Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                              Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved