mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Only show user displayable portion of server errors when seleting a song in multiplayer
This commit is contained in:
parent
6ebe54b183
commit
284e554cbf
@ -1,6 +1,9 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
@ -60,13 +63,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
loadingLayer.Hide();
|
||||
|
||||
if (t.IsCompletedSuccessfully)
|
||||
this.Exit();
|
||||
else
|
||||
if (t.IsFaulted)
|
||||
{
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
this.Exit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user