From 6dd2b464a33284d32aa01990203ab164cb282428 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 9 Jul 2020 01:31:27 +0900 Subject: [PATCH] NRE on head request with invalid url #108 --- .../Runtime/UnityWebRequestException.cs | 13 ++++++++++- src/UniTask/Assets/Scenes/SandboxMain.cs | 22 +++---------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs index df61999..6dd1168 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs @@ -32,6 +32,10 @@ namespace Cysharp.Threading.Tasks this.Error = unityWebRequest.error; this.ResponseCode = unityWebRequest.responseCode; this.Text = unityWebRequest.downloadHandler.text; + if (UnityWebRequest.downloadHandler != null) + { + this.Text = unityWebRequest.downloadHandler.text; + } } public override string Message @@ -40,7 +44,14 @@ namespace Cysharp.Threading.Tasks { if (msg == null) { - msg = Error + Environment.NewLine + Text; + if (Text != null) + { + msg = Error + Environment.NewLine + Text; + } + else + { + msg = Error; + } } return msg; } diff --git a/src/UniTask/Assets/Scenes/SandboxMain.cs b/src/UniTask/Assets/Scenes/SandboxMain.cs index 83a80b4..f84ced7 100644 --- a/src/UniTask/Assets/Scenes/SandboxMain.cs +++ b/src/UniTask/Assets/Scenes/SandboxMain.cs @@ -476,25 +476,9 @@ public class SandboxMain : MonoBehaviour async UniTaskVoid Start() { - var cts = new CancellationTokenSource(); - okButton.onClick.AddListener(() => - { - cts.Cancel(); - }); - - //// Nanika(); - - - //await UniTask.Yield(); - - - await MyEveryUpdate().Select(x => x).Where(x => x % 2 == 0).ForEachAsync(x => - { - UnityEngine.Debug.Log(x + ":" + Time.frameCount); - }, cts.Token); - - - // this.GetCancellationTokenOnDestroy() + var url = "http://fooooooooooooooooooooooooooooooooooo.com"; + var webRequestAsyncOperation = UnityWebRequest.Head(url).SendWebRequest(); + await webRequestAsyncOperation.ToUniTask(); //PlayerLoopInfo.Inject();