Hello everyone!
I have a WebService doing requests to a database and a proxy class on my Unity Project to call the service.
I have this snippet of code: public IEnumerator LoginOperation() { try{ LoginInfo = webService.Login(Username, Password); yield return LoginInfo; // Do other stuff here } catch(Exception e) { Debug.Log("There was an error while contacting the Service"); Debug.LogError(e.Message); } }
That would do the job perfectly if it wasn't for this error: Cannot yield in the body of a catch clause I need the yield return to let the loading icon spin and not freeze the client while the Service is performing the request, and still i need the try catch block to handle errors (for example if the service is offline).
How can i do that? I've been stuck by 2 days trying to find a solution without succeed.Thanks to everyone who will answer.
I have a WebService doing requests to a database and a proxy class on my Unity Project to call the service.
I have this snippet of code: public IEnumerator LoginOperation() { try{ LoginInfo = webService.Login(Username, Password); yield return LoginInfo; // Do other stuff here } catch(Exception e) { Debug.Log("There was an error while contacting the Service"); Debug.LogError(e.Message); } }
That would do the job perfectly if it wasn't for this error: Cannot yield in the body of a catch clause I need the yield return to let the loading icon spin and not freeze the client while the Service is performing the request, and still i need the try catch block to handle errors (for example if the service is offline).
How can i do that? I've been stuck by 2 days trying to find a solution without succeed.Thanks to everyone who will answer.