NRE on head request with invalid url #108

pull/115/head
neuecc 2020-07-09 01:31:27 +09:00
parent 32f24cf8f8
commit 6dd2b464a3
2 changed files with 15 additions and 20 deletions

View File

@ -32,6 +32,10 @@ namespace Cysharp.Threading.Tasks
this.Error = unityWebRequest.error; this.Error = unityWebRequest.error;
this.ResponseCode = unityWebRequest.responseCode; this.ResponseCode = unityWebRequest.responseCode;
this.Text = unityWebRequest.downloadHandler.text; this.Text = unityWebRequest.downloadHandler.text;
if (UnityWebRequest.downloadHandler != null)
{
this.Text = unityWebRequest.downloadHandler.text;
}
} }
public override string Message public override string Message
@ -39,9 +43,16 @@ namespace Cysharp.Threading.Tasks
get get
{ {
if (msg == null) if (msg == null)
{
if (Text != null)
{ {
msg = Error + Environment.NewLine + Text; msg = Error + Environment.NewLine + Text;
} }
else
{
msg = Error;
}
}
return msg; return msg;
} }
} }

View File

@ -476,25 +476,9 @@ public class SandboxMain : MonoBehaviour
async UniTaskVoid Start() async UniTaskVoid Start()
{ {
var cts = new CancellationTokenSource(); var url = "http://fooooooooooooooooooooooooooooooooooo.com";
okButton.onClick.AddListener(() => var webRequestAsyncOperation = UnityWebRequest.Head(url).SendWebRequest();
{ await webRequestAsyncOperation.ToUniTask();
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()
//PlayerLoopInfo.Inject(); //PlayerLoopInfo.Inject();