mirror of
https://github.com/ppy/osu.git
synced 2025-03-10 22:17:20 +08:00
Replace error handling with logs
- Handling all errors matches master a little bit better. Logging exceptions in any case. - Not throwing when beatmaps are missing simplifies tests.
This commit is contained in:
parent
c7fd7cf9cd
commit
3dde024650
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -131,10 +132,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
return await transformScores(allScores).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return await fetchScoresAround().ConfigureAwait(false);
|
||||
@ -192,8 +189,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
return await transformScores(index.Scores).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Failed to fetch scores (room: {RoomId}, item: {PlaylistItem.ID}): {ex}");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -242,7 +240,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
foreach (int id in allBeatmapIds)
|
||||
{
|
||||
if (!beatmapsById.ContainsKey(id))
|
||||
throw new MissingBeatmapException(PlaylistItem, id);
|
||||
{
|
||||
Logger.Log($"Failed to fetch beatmap {id} to display scores for playlist item {PlaylistItem.ID}");
|
||||
beatmapsById[id] = Beatmap.Value.BeatmapInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude the score provided to this screen since it's added already.
|
||||
@ -313,13 +314,5 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
X = (float)(list.ScrollableExtent - list.Current - panelOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private class MissingBeatmapException : Exception
|
||||
{
|
||||
public MissingBeatmapException(PlaylistItem item, int beatmapId)
|
||||
: base($"Missing beatmap {beatmapId} for playlist item {item.ID}")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API;
|
||||
@ -72,8 +73,9 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
return toDisplay.ToArray();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Failed to fetch scores (beatmap: {Score.BeatmapInfo}, ruleset: {Score.Ruleset}): {ex}");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user