mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 18:42:56 +08:00
Remove all usage of CatchUnobservedExceptions
This should no longer be required with the recent framework side change that stops a game from crashing on unobserved exceptions (https://github.com/ppy/osu-framework/pull/4171).
This commit is contained in:
parent
4c4770bf4b
commit
a61444690e
@ -1,36 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework.Extensions.ExceptionExtensions;
|
|
||||||
using osu.Framework.Logging;
|
|
||||||
|
|
||||||
namespace osu.Game.Extensions
|
|
||||||
{
|
|
||||||
public static class TaskExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Denote a task which is to be run without local error handling logic, where failure is not catastrophic.
|
|
||||||
/// Avoids unobserved exceptions from being fired.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="task">The task.</param>
|
|
||||||
/// <param name="logAsError">
|
|
||||||
/// Whether errors should be logged as errors visible to users, or as debug messages.
|
|
||||||
/// Logging as debug will essentially silence the errors on non-release builds.
|
|
||||||
/// </param>
|
|
||||||
public static void CatchUnobservedExceptions(this Task task, bool logAsError = false)
|
|
||||||
{
|
|
||||||
task.ContinueWith(t =>
|
|
||||||
{
|
|
||||||
Exception? exception = t.Exception?.AsSingular();
|
|
||||||
if (logAsError)
|
|
||||||
Logger.Error(exception, $"Error running task: {exception?.Message ?? "(unknown)"}", LoggingTarget.Runtime, true);
|
|
||||||
else
|
|
||||||
Logger.Log($"Error running task: {exception}", LoggingTarget.Runtime, LogLevel.Debug);
|
|
||||||
}, TaskContinuationOptions.NotOnRanToCompletion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -104,7 +103,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
if (!connected.NewValue && Room != null)
|
if (!connected.NewValue && Room != null)
|
||||||
{
|
{
|
||||||
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
||||||
LeaveRoom().CatchUnobservedExceptions();
|
LeaveRoom();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
@ -23,7 +22,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
|
||||||
if (client.Room != null)
|
if (client.Room != null)
|
||||||
client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
|
client.ChangeState(MultiplayerUserState.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdatePollingRate(bool isIdle)
|
protected override void UpdatePollingRate(bool isIdle)
|
||||||
|
@ -11,7 +11,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
@ -237,7 +236,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
// accessing Exception here silences any potential errors from the antecedent task
|
// accessing Exception here silences any potential errors from the antecedent task
|
||||||
if (t.Exception != null)
|
if (t.Exception != null)
|
||||||
{
|
{
|
||||||
t.CatchUnobservedExceptions(true); // will run immediately.
|
|
||||||
// gameplay was not started due to an exception; unblock button.
|
// gameplay was not started due to an exception; unblock button.
|
||||||
endOperation();
|
endOperation();
|
||||||
}
|
}
|
||||||
@ -248,11 +246,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.ToggleReady()
|
client.ToggleReady()
|
||||||
.ContinueWith(t =>
|
.ContinueWith(t => endOperation());
|
||||||
{
|
|
||||||
t.CatchUnobservedExceptions(true); // will run immediately.
|
|
||||||
endOperation();
|
|
||||||
});
|
|
||||||
|
|
||||||
void endOperation()
|
void endOperation()
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ExceptionExtensions;
|
using osu.Framework.Extensions.ExceptionExtensions;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Rooms.RoomStatuses;
|
using osu.Game.Online.Rooms.RoomStatuses;
|
||||||
@ -69,7 +68,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
base.PartRoom();
|
base.PartRoom();
|
||||||
|
|
||||||
multiplayerClient.LeaveRoom().CatchUnobservedExceptions();
|
multiplayerClient.LeaveRoom();
|
||||||
|
|
||||||
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
|
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
|
||||||
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.
|
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.
|
||||||
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -176,7 +175,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
if (Room.Host?.UserID != api.LocalUser.Value.Id)
|
if (Room.Host?.UserID != api.LocalUser.Value.Id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Client.TransferHost(targetUser).CatchUnobservedExceptions(true);
|
Client.TransferHost(targetUser);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user