Code: Select all
client.DownloadString(); //handles exceptions
client.DownloadStringAsync(); // does NOT handle exceptions
client.DownloadStringTaskAsync(); // does NOT handle exceptions
For example, if I take my API down and attempt to authenticate with it, in Simulator I get an exception,
Unable to connect to the remote server at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address)
I can catch this error in a try/catch block, and then notify the user of the error and prevent further execution of my task.
In the JS output, I get no exception, just the following error in the js console:
Failed to load resource: net::ERR_CONNECTION_REFUSED
This does NOT get caught in a try/catch block, I cannot notify the user of the error, and it does not prevent further execution of my task.
My current workaround is to only use `client.DownloadString()`, instead of any of the async methods.