mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Only show user displayable portion of server errors when seleting a song in multiplayer
This commit is contained in:
@ -1,6 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
@ -60,13 +63,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
loadingLayer.Hide();
|
loadingLayer.Hide();
|
||||||
|
|
||||||
if (t.IsCompletedSuccessfully)
|
if (t.IsFaulted)
|
||||||
this.Exit();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Logger.Log($"Could not use current beatmap ({t.Exception?.Message})", level: LogLevel.Important);
|
Exception exception = t.Exception;
|
||||||
|
|
||||||
|
if (exception is AggregateException ae)
|
||||||
|
exception = ae.InnerException;
|
||||||
|
|
||||||
|
Debug.Assert(exception != null);
|
||||||
|
|
||||||
|
string message = exception is HubException
|
||||||
|
// HubExceptions arrive with additional message context added, but we want to display the human readable message:
|
||||||
|
// "An unexpected error occurred invoking 'AddPlaylistItem' on the server.InvalidStateException: Can't enqueue more than 3 items at once."
|
||||||
|
// We generally use the message field for a user-parseable error (eventually to be replaced), so drop the first part for now.
|
||||||
|
? exception.Message.Substring(exception.Message.IndexOf(':') + 1).Trim()
|
||||||
|
: exception.Message;
|
||||||
|
|
||||||
|
Logger.Log(message, level: LogLevel.Important);
|
||||||
Carousel.AllowSelection = true;
|
Carousel.AllowSelection = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Exit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user