Skip to content

Commit 73da0e1

Browse files
committed
Improves offline message detection on Android
1 parent 85f2141 commit 73da0e1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Float.Core/Extensions/Exception.extensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public static bool IsOfflineException(this Exception e)
3737
return true;
3838
}
3939

40+
// On Android, the message might literally be "Connection failure"
41+
// (see https://github.com/dotnet/android/blob/688245d397097fbc8e70fd291abe11143f1c3553/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs#L577)
42+
if (e.Message == "Connection failure")
43+
{
44+
return true;
45+
}
46+
4047
// we sometimes get a webexception status of NameResolutionFailure that we don't have access to, but its enum value is one
4148
if (e.InnerException is WebException webException && ((int)webException.Status == 1 || webException.Status == WebExceptionStatus.ConnectFailure))
4249
{

0 commit comments

Comments
 (0)