public WebRequestErrorException(UnityWebRequest request) { this.WebRequest = request; this.Method = request.method; this.RawErrorMessage = request.error; this.ResponseHeaders = request.GetResponseHeaders(); this.HasResponse = false; this.StatusCode = (System.Net.HttpStatusCode)request.responseCode; var splitted = RawErrorMessage.Split(' ', ':'); if (splitted.Length != 0) { int statusCode; if (int.TryParse(splitted[0], out statusCode)) { this.HasResponse = true; //this.StatusCode = (System.Net.HttpStatusCode)statusCode; } } var handler = request.downloadHandler; if (handler != null && handler.GetType() != typeof(DownloadHandlerAssetBundle)) // DownloadHandlerAssetBundle will throw a NotSupportedException if text property is called. { this.Text = request.downloadHandler.text; } }
public WWWErrorException(WWW www) { WWW = www; RawErrorMessage = www.error; ResponseHeaders = www.responseHeaders; HasResponse = false; string[] array = RawErrorMessage.Split(' '); if (array.Length != 0 && int.TryParse(array[0], out int result)) { HasResponse = true; StatusCode = (HttpStatusCode)result; } }
public WWWErrorException(WWW www) { this.WWW = www; this.RawErrorMessage = www.error; this.ResponseHeaders = www.responseHeaders; this.HasResponse = false; var splitted = RawErrorMessage.Split(' '); if (splitted.Length != 0) { int statusCode; if (int.TryParse(splitted[0], out statusCode)) { this.HasResponse = true; this.StatusCode = (System.Net.HttpStatusCode)statusCode; } } }
// cache the text because if www was disposed, can't access it. public WWWErrorException(UnityWebRequest www, string text) { this.WWW = www; this.RawErrorMessage = www.error; this.ResponseHeaders = www.GetResponseHeaders(); this.HasResponse = false; this.Text = text; var splitted = RawErrorMessage.Split(' ', ':'); if (splitted.Length != 0) { int statusCode; if (int.TryParse(splitted[0], out statusCode)) { this.HasResponse = true; this.StatusCode = (System.Net.HttpStatusCode)statusCode; } } }
public WWWErrorException(WWW www) { this.WWW = www; this.RawErrorMessage = www.error; this.ResponseHeaders = www.responseHeaders; this.HasResponse = false; this.Text = www.text; // cache the text because if www was disposed, can't access it. var splitted = RawErrorMessage.Split(' ', ':'); if (splitted.Length != 0) { int statusCode; if (int.TryParse(splitted[0], out statusCode)) { this.HasResponse = true; this.StatusCode = (System.Net.HttpStatusCode)statusCode; } } }