Skip to content

Commit

Permalink
Merge pull request #27077 from peppy/log-fire-and-forget-better
Browse files Browse the repository at this point in the history
Improve exception logging of unobserved exceptions via `FireAndForget`
  • Loading branch information
bdach authored Feb 10, 2024
2 parents bd22685 + 0d7e82a commit 4a516cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public static void FireAndForget(this Task task, Action? onSuccess = null, Actio
Debug.Assert(exception != null);
string message = exception.GetHubExceptionMessage() ?? exception.Message;
if (exception.GetHubExceptionMessage() is string message)
// Hub exceptions generally contain something we can show the user directly.
Logger.Log(message, level: LogLevel.Important);
else
Logger.Error(exception, $"Unobserved exception occurred via {nameof(FireAndForget)} call: {exception.Message}");
Logger.Log(message, level: LogLevel.Important);
onError?.Invoke(exception);
}
else
Expand Down

0 comments on commit 4a516cb

Please sign in to comment.