diff --git a/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs b/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs index 61824914b5..83d9e64a36 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs @@ -3,11 +3,11 @@ using System; using System.Diagnostics; -using System.Net.WebSockets; using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; using osu.Framework.Extensions.ExceptionExtensions; using osu.Framework.Logging; +using osu.Game.Utils; namespace osu.Game.Online.Multiplayer { @@ -23,12 +23,10 @@ namespace osu.Game.Online.Multiplayer onError?.Invoke(exception); - if (exception is WebSocketException wse && wse.Message == @"The remote party closed the WebSocket connection without completing the close handshake.") - { - // OnlineStatusNotifier is already letting users know about interruptions to connections. - // Silence these because it gets very spammy otherwise. + // OnlineStatusNotifier is already letting users know about interruptions to connections. + // Silence these because it gets very spammy otherwise. + if (SentryLogger.IsLocalUserConnectivityException(exception)) return; - } if (exception.GetHubExceptionMessage() is string message) { diff --git a/osu.Game/Utils/SentryLogger.cs b/osu.Game/Utils/SentryLogger.cs index 96453474aa..3cc23264fb 100644 --- a/osu.Game/Utils/SentryLogger.cs +++ b/osu.Game/Utils/SentryLogger.cs @@ -239,6 +239,9 @@ namespace osu.Game.Utils private bool shouldSubmitException(Exception exception) { + if (IsLocalUserConnectivityException(exception)) + return false; + switch (exception) { // disk I/O failures, invalid formats, etc. @@ -253,27 +256,7 @@ namespace osu.Game.Utils case SharpCompress.Common.InvalidFormatException: return false; - // connectivity failures - - case TimeoutException te: - return !te.Message.Contains(@"elapsed without receiving a message from the server"); - - case WebException we: - switch (we.Status) - { - // more statuses may need to be blocked as we come across them. - case WebExceptionStatus.Timeout: - return false; - } - - break; - - case WebSocketException: - case SocketException: - return false; - // stuff that should really never make it to sentry - case APIAccess.WebRequestFlushedException: case TaskCanceledException: return false; @@ -282,6 +265,25 @@ namespace osu.Game.Utils return true; } + public static bool IsLocalUserConnectivityException(Exception exception) + { + switch (exception) + { + case TimeoutException te: + return te.Message.Contains(@"elapsed without receiving a message from the server"); + + case WebException we: + // more statuses may need to be blocked as we come across them. + return we.Status == WebExceptionStatus.Timeout; + + case WebSocketException: + case SocketException: + return true; + } + + return false; + } + #region Disposal public void Dispose()