Skip to content

Commit

Permalink
Improves offline message detection on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
mediabounds committed Jul 23, 2024
1 parent 85f2141 commit 73da0e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Float.Core/Extensions/Exception.extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public static bool IsOfflineException(this Exception e)
return true;
}

// On Android, the message might literally be "Connection failure"
// (see https://github.com/dotnet/android/blob/688245d397097fbc8e70fd291abe11143f1c3553/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs#L577)
if (e.Message == "Connection failure")
{
return true;
}

// we sometimes get a webexception status of NameResolutionFailure that we don't have access to, but its enum value is one
if (e.InnerException is WebException webException && ((int)webException.Status == 1 || webException.Status == WebExceptionStatus.ConnectFailure))
{
Expand Down

0 comments on commit 73da0e1

Please sign in to comment.