Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

UnityWebRequest isNetworkError and HttpError replacement question

Discussion in 'Multiplayer' started by xeonheart, May 31, 2021.

  1. xeonheart

    xeonheart

    Joined:
    Jul 24, 2018
    Posts:
    114
    hello,

    so i am using the UnityWebRequest class, and i see its error is saying the isNetworkError and HTTPError is deprecated or no longer being used... so should i use error property? or is there a better way to capture if there is an error? right now I replaced it from:

    Code (CSharp):
    1. UnityWebRequest request;
    2.  
    3.                 if (request.isNetworkError || request.isHttpError)
    4.                 {
    5.                     errorCallback(request.error);
    6.                 }
    7.                 else
    8.                 {
    9.                     successCallback(request.downloadHandler.data);
    10.                 }
    the new WAY i think... but correct me if i am wrong or if there is a better way:

    Code (CSharp):
    1.                 if (request.error != null)
    2.                 {
    3.                     errorCallback(request.error);
    4.                 }
    5.                 else
    6.                 {
    7.                     successCallback(request.downloadHandler.data);
    8.                 }
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,012
unityunity