From d1d82d2b4952a179b5d55ac6f1ed144d07770993 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Sep 2023 15:00:56 +0900 Subject: [PATCH 1/2] Improve notification display when score import fails --- osu.Game/Database/RealmArchiveModelImporter.cs | 2 +- osu.Game/Scoring/ScoreImporter.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/RealmArchiveModelImporter.cs b/osu.Game/Database/RealmArchiveModelImporter.cs index 9d06c14b4b..d2de00d476 100644 --- a/osu.Game/Database/RealmArchiveModelImporter.cs +++ b/osu.Game/Database/RealmArchiveModelImporter.cs @@ -149,7 +149,7 @@ namespace osu.Game.Database return imported; } - notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!"; + notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed! Check logs for more information."; notification.State = ProgressNotificationState.Cancelled; } else diff --git a/osu.Game/Scoring/ScoreImporter.cs b/osu.Game/Scoring/ScoreImporter.cs index b85b6a066e..5af53c6f7b 100644 --- a/osu.Game/Scoring/ScoreImporter.cs +++ b/osu.Game/Scoring/ScoreImporter.cs @@ -62,6 +62,11 @@ namespace osu.Game.Scoring api.Queue(req); return null; } + catch (Exception) + { + Logger.Log($@"Score '{archive.Name}' failed to import: failed to parse replay headers.", LoggingTarget.Database); + return null; + } } } From 3708e79577472e2c5284fc635eb65a9dd022545f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 27 Sep 2023 16:55:03 +0900 Subject: [PATCH 2/2] Adjust logging to still expose the underlying exception --- osu.Game/Scoring/ScoreImporter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Scoring/ScoreImporter.cs b/osu.Game/Scoring/ScoreImporter.cs index 5af53c6f7b..2314dbb63b 100644 --- a/osu.Game/Scoring/ScoreImporter.cs +++ b/osu.Game/Scoring/ScoreImporter.cs @@ -52,19 +52,19 @@ namespace osu.Game.Scoring { return new DatabasedLegacyScoreDecoder(rulesets, beatmaps()).Parse(stream).ScoreInfo; } - catch (LegacyScoreDecoder.BeatmapNotFoundException e) + catch (LegacyScoreDecoder.BeatmapNotFoundException notFound) { - Logger.Log($@"Score '{archive.Name}' failed to import: no corresponding beatmap with the hash '{e.Hash}' could be found.", LoggingTarget.Database); + Logger.Log($@"Score '{archive.Name}' failed to import: no corresponding beatmap with the hash '{notFound.Hash}' could be found.", LoggingTarget.Database); // In the case of a missing beatmap, let's attempt to resolve it and show a prompt to the user to download the required beatmap. - var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = e.Hash }); - req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, e.Hash)); + var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = notFound.Hash }); + req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, notFound.Hash)); api.Queue(req); return null; } - catch (Exception) + catch (Exception e) { - Logger.Log($@"Score '{archive.Name}' failed to import: failed to parse replay headers.", LoggingTarget.Database); + Logger.Log($@"Failed to parse headers of score '{archive.Name}': {e}.", LoggingTarget.Database); return null; } }