From c2538da1cd0dd4381c695a673db0c867215a433e Mon Sep 17 00:00:00 2001 From: neuecc Date: Fri, 19 Jun 2020 16:45:55 +0900 Subject: [PATCH] Improve UnityWebRequestError performance --- .../UniTask/Runtime/UnityWebRequestError.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestError.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestError.cs index c5fe3ff..0005e4e 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestError.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestError.cs @@ -10,13 +10,30 @@ namespace Cysharp.Threading.Tasks public UnityWebRequest UnityWebRequest { get; } public bool IsNetworkError { get; } public bool IsHttpError { get; } + public string Error { get; } + public string Text { get; } + + string msg; public UnityWebRequestException(UnityWebRequest unityWebRequest) - : base(unityWebRequest.error + Environment.NewLine + unityWebRequest.downloadHandler.text) { this.UnityWebRequest = unityWebRequest; this.IsNetworkError = unityWebRequest.isNetworkError; this.IsHttpError = unityWebRequest.isHttpError; + this.Error = unityWebRequest.error; + this.Text = unityWebRequest.downloadHandler.text; + } + + public override string Message + { + get + { + if (msg == null) + { + msg = Error + Environment.NewLine + Text; + } + return msg; + } } } }