Skip to content

Commit

Permalink
Improve exception logging of unobserved exceptions via FireAndForget
Browse files Browse the repository at this point in the history
Coming from #27076, where the log
output makes finding where the exception arrived for nigh impossible.
  • Loading branch information
peppy committed Feb 7, 2024
1 parent 7460d07 commit 0d7e82a
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 0d7e82a

Please sign in to comment.