How to handle UnityWebRequest Errors when throws Curl 28 Error
I want to handle when web request throw an error.
UnityWebRequest webRequest = UnityWebRequest.Post("www.webpage.com", form);
webRequest.timeout = 3;
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
Debug.Log("Error: time out");
}
var s = webRequest.downloadHandler.text;
This script throws an exception Curl error 28: Connection timed out after 2000 milliseconds.
I tried to put webRequest.,isNetwotkError
into the try catch block but it does not work the application crashed. What do you advice ? How can I handle the network errors ?
Same here. I am spawning a bunch of requests that I know will likely fail. I'd like them to fail quietly without spam$$anonymous$$g the console. Has anyone found a solution? Thanks!
Answer by xxmariofer · Oct 07, 2021 at 06:12 AM
the only solution is changing the code from coroutine to async methods and use try catch
I have tried that and the curl messages aren't caught by the catch block . Have you successfully implemented that?
Your answer
Follow this Question
Related Questions
NetworkClient Send with no Connection 0 Answers
How to create a rest authentication header in unity 1 Answer
MultipartFormDataSection not working - Error: 403 0 Answers
Referencing a function in a C# script 1 Answer
Cannot convert String to int 1 Answer