Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

handle HttpClient error

$
0
0

I'm trying to intercept the HTTP client error in case the server is non-existent or down.

i use this code:

HttpResponseMessage response;
            try
            {
                 response = await _client.GetAsync("CallApiXamarin/" + User);
            }
            catch (Exception ex) when (ex is TaskCanceledException || ex is OperationCanceledException)
            {

                throw;
            }

But the APP hangs in debugging by showing this message:

Unhandled Exception:

System.Threading.Tasks.TaskCanceledException: A task was canceled.

What should I do?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>