1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #19522 from frenzibyte/improve-download-limit-message

Display readable error message when reaching download limit
This commit is contained in:
Dean Herbert 2022-08-03 23:32:04 +09:00 committed by GitHub
commit 1eb8168a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 2 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Humanizer;
using osu.Framework.Logging;
@ -107,7 +108,15 @@ namespace osu.Game.Database
notification.State = ProgressNotificationState.Cancelled;
if (!(error is OperationCanceledException))
Logger.Error(error, $"{importer.HumanisedModelName.Titleize()} download failed!");
{
if (error is WebException webException && webException.Message == @"TooManyRequests")
{
notification.Close();
PostNotification?.Invoke(new TooManyDownloadsNotification());
}
else
Logger.Error(error, $"{importer.HumanisedModelName.Titleize()} download failed!");
}
}
}

View File

@ -0,0 +1,26 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Overlays.Notifications;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Database
{
public class TooManyDownloadsNotification : SimpleNotification
{
public TooManyDownloadsNotification()
{
Text = BeatmapsetsStrings.DownloadLimitExceeded;
Icon = FontAwesome.Solid.ExclamationCircle;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
IconBackground.Colour = colours.RedDark;
}
}
}

View File

@ -1,4 +1,4 @@
// 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.
using osu.Framework.Localisation;