Search Unity

Bug Errors not catchable

Discussion in 'Authentication' started by DavidZobrist, Jul 17, 2022.

  1. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    234
    I am on the task to handling the potential lose of internet connection at different points in my app.
    So starting with auth. I struggle to properly catch the errors. Errors pause the editor.

    Code (CSharp):
    1.  try
    2.                     {
    3.                        await AuthenticationService.Instance.SignInAnonymouslyAsync();
    4.                     }
    5.                     catch (AuthenticationException ex)
    6.                     {
    7.                         Debug.LogException(ex);
    8.                     }
    9.                     catch (RequestFailedException ex)
    10.                     {
    11.                         Debug.LogException(ex);
    12.                
    13.                 }

    I also did it in a seperate function returning a task as mentioned here:
    https://docs.unity.com/authentication/UsingAnonSignIn.html

    Still the errors are not catched!
    The only time I get the error message printed myself is through an event subscription

    Code (CSharp):
    1. AuthenticationService.Instance.SignInFailed += OnFailedSignIn;
    upload_2022-7-17_15-0-31.png
     
  2. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    234
    Nevermind I just realized we are logging as Exception. After changing both to Debug.Log(
    ex);

    Only one error remains, but still editor stopping.

    Code (CSharp):
    1. [Authentication]: Request failed: 0, Cannot resolve destination host
     
  3. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    234
    Its that one coming from the Service api:
    upload_2022-7-17_16-6-20.png

    Is there another way of solving that so we dont have the editor paused?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have Error Pause on for the Console window in the Unity Editor?
     
  5. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    234
    Hi @JeffDUnity3D,
    yes your right I did not know I can turn this off, thanks!

    But still shouldnt I be able to catch all errors?
    I dont like seeing red stuff in the console. Would be nice if the try catch just prevents that message.
    upload_2022-7-22_23-56-4.png

    Maybe its just a nice to have..
     
  6. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    We will look to remove unwanted error logs, we agree they should not be forced on you if you are handling the exceptions
     
    DavidZobrist likes this.