Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    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:
    100
    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:
    2,941
unityunity