Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Catch clauses being ignored on Release builds

$
0
0

I have been receiving crash logs in my Apps due to exceptions that were supposedly being caught but are crashing the application and I am able to consistently reproduce the issue on my devices. The crashes are usually inside a async method (all methods are being awaited) of my Core PCL library, but the exception is being caught and handled correctly on simulator and Debug builds, but crashes on Release builds for real devices.

At some point I have empty catch clauses to retry failed connections like this:

public async Task<T> GetAsync<T>(string url, CancellationToken cancellationToken) where T : new()
{
    var retryCount = 0;
    while (retryCount++ < RetryLimit)
    {
        try {
            Mvx.Trace(MvxTraceLevel.Diagnostic, "Get request with URL: {0}", url);
            using (var client = new HttpClient { Timeout = requestTimeout }) {
                var response = await client.GetAsync(url, cancellationToken);
                // Process response and generate result
                return result;
            }
        }
        catch (TaskCanceledException) {
            Mvx.Trace("Failed attempt {0} for URL {1}...", retryCount, url);
        }
    }
    throw new TimeoutException();
}

But I'm still receiving TaskCanceledException in my crash logs.

Am I missing something? Is it a bug? Is someone else having this issue?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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