1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 11:02:54 +08:00

Add messages to all InvalidOperationExceptions

Without this, they can be very non-descript and hard to track down
This commit is contained in:
Dean Herbert 2022-06-28 01:34:24 +09:00
parent d43b980a17
commit 569fde4b47
8 changed files with 14 additions and 14 deletions

View File

@ -83,14 +83,14 @@ namespace osu.Game.Tests.NonVisual
public override event Action<JudgementResult> NewResult public override event Action<JudgementResult> NewResult
{ {
add => throw new InvalidOperationException(); add => throw new InvalidOperationException($"{nameof(NewResult)} operations not supported in test context");
remove => throw new InvalidOperationException(); remove => throw new InvalidOperationException($"{nameof(NewResult)} operations not supported in test context");
} }
public override event Action<JudgementResult> RevertResult public override event Action<JudgementResult> RevertResult
{ {
add => throw new InvalidOperationException(); add => throw new InvalidOperationException($"{nameof(RevertResult)} operations not supported in test context");
remove => throw new InvalidOperationException(); remove => throw new InvalidOperationException($"{nameof(RevertResult)} operations not supported in test context");
} }
public override Playfield Playfield { get; } public override Playfield Playfield { get; }

View File

@ -273,14 +273,14 @@ namespace osu.Game.Tests.Visual.Gameplay
public override event Action<JudgementResult> NewResult public override event Action<JudgementResult> NewResult
{ {
add => throw new InvalidOperationException(); add => throw new InvalidOperationException($"{nameof(NewResult)} operations not supported in test context");
remove => throw new InvalidOperationException(); remove => throw new InvalidOperationException($"{nameof(NewResult)} operations not supported in test context");
} }
public override event Action<JudgementResult> RevertResult public override event Action<JudgementResult> RevertResult
{ {
add => throw new InvalidOperationException(); add => throw new InvalidOperationException($"{nameof(RevertResult)} operations not supported in test context");
remove => throw new InvalidOperationException(); remove => throw new InvalidOperationException($"{nameof(RevertResult)} operations not supported in test context");
} }
public override Playfield Playfield { get; } public override Playfield Playfield { get; }

View File

@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
{ {
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException(), Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException("osu!mania ruleset not found"),
Difficulty = new BeatmapDifficulty Difficulty = new BeatmapDifficulty
{ {
CircleSize = 5, CircleSize = 5,

View File

@ -88,7 +88,7 @@ namespace osu.Game.Online.API.Requests.Responses
/// <returns></returns> /// <returns></returns>
public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null) public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = null)
{ {
var ruleset = rulesets.GetRuleset(RulesetID) ?? throw new InvalidOperationException(); var ruleset = rulesets.GetRuleset(RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {RulesetID} not found locally");
var rulesetInstance = ruleset.CreateInstance(); var rulesetInstance = ruleset.CreateInstance();

View File

@ -79,7 +79,7 @@ namespace osu.Game.Online.Rooms
TotalScore = TotalScore, TotalScore = TotalScore,
MaxCombo = MaxCombo, MaxCombo = MaxCombo,
BeatmapInfo = beatmap, BeatmapInfo = beatmap,
Ruleset = rulesets.GetRuleset(playlistItem.RulesetID) ?? throw new InvalidOperationException(), Ruleset = rulesets.GetRuleset(playlistItem.RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {playlistItem.RulesetID} not found locally"),
Statistics = Statistics, Statistics = Statistics,
User = User, User = User,
Accuracy = Accuracy, Accuracy = Accuracy,

View File

@ -136,7 +136,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Spacing = new Vector2(2), Spacing = new Vector2(2),
Children = Score.Mods.Select(mod => Children = Score.Mods.Select(mod =>
{ {
var ruleset = rulesets.GetRuleset(Score.RulesetID) ?? throw new InvalidOperationException(); var ruleset = rulesets.GetRuleset(Score.RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {Score.RulesetID} not found locally");
return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym)) return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym))
{ {

View File

@ -122,7 +122,7 @@ namespace osu.Game.Screens.Edit
public BeatmapInfo BeatmapInfo public BeatmapInfo BeatmapInfo
{ {
get => beatmapInfo; get => beatmapInfo;
set => throw new InvalidOperationException(); set => throw new InvalidOperationException($"Can't set {nameof(BeatmapInfo)} on {nameof(EditorBeatmap)}");
} }
public BeatmapMetadata Metadata => beatmapInfo.Metadata; public BeatmapMetadata Metadata => beatmapInfo.Metadata;

View File

@ -134,7 +134,7 @@ namespace osu.Game.Tests.Visual.Spectator
FrameSendAttempts++; FrameSendAttempts++;
if (ShouldFailSendingFrames) if (ShouldFailSendingFrames)
return Task.FromException(new InvalidOperationException()); return Task.FromException(new InvalidOperationException($"Intentional fail via {ShouldFailSendingFrames}"));
return ((ISpectatorClient)this).UserSentFrames(api.LocalUser.Value.Id, bundle); return ((ISpectatorClient)this).UserSentFrames(api.LocalUser.Value.Id, bundle);
} }