1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 10:33:07 +08:00

Merge pull request #11270 from bdach/better-error-handling

Improve error handling at realtime room settings screen
This commit is contained in:
Dean Herbert 2020-12-24 13:23:49 +09:00 committed by GitHub
commit b29a5e2073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -122,7 +122,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
protected override Task<MultiplayerRoom> JoinRoom(long roomId)
{
if (!isConnected.Value)
return Task.FromCanceled<MultiplayerRoom>(CancellationToken.None);
return Task.FromCanceled<MultiplayerRoom>(new CancellationToken(true));
return connection.InvokeAsync<MultiplayerRoom>(nameof(IMultiplayerServer.JoinRoom), roomId);
}

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ExceptionExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -299,7 +300,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
if (t.IsCompletedSuccessfully)
onSuccess(currentRoom.Value);
else
onError(t.Exception?.Message ?? "Error changing settings.");
onError(t.Exception?.AsSingular().Message ?? "Error changing settings.");
}));
}
else

View File

@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ExceptionExtensions;
using osu.Framework.Logging;
using osu.Game.Extensions;
using osu.Game.Online.Multiplayer;
@ -91,11 +92,13 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
Schedule(() => onSuccess?.Invoke(room));
else
{
const string message = "Failed to join multiplayer room.";
if (t.Exception != null)
Logger.Error(t.Exception, "Failed to join multiplayer room.");
Logger.Error(t.Exception, message);
PartRoom();
Schedule(() => onError?.Invoke(t.Exception?.ToString() ?? string.Empty));
Schedule(() => onError?.Invoke(t.Exception?.AsSingular().Message ?? message));
}
});
}