CA2208: create exceptions correctly.

This commit is contained in:
Huo Yaoyuan 2019-11-28 22:21:21 +08:00
parent 09257b0c6d
commit d5994ed484
8 changed files with 8 additions and 9 deletions

View File

@ -51,7 +51,6 @@
<Rule Id="CA1826" Action="None" />
<Rule Id="CA2000" Action="None" />
<Rule Id="CA2008" Action="None" />
<Rule Id="CA2208" Action="None" />
<Rule Id="CA2213" Action="None" />
<Rule Id="CA2235" Action="None" />
</Rules>

View File

@ -119,7 +119,7 @@ namespace osu.Game.Graphics
break;
default:
throw new ArgumentOutOfRangeException(nameof(screenshotFormat));
throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}.");
}
notificationOverlay.Post(new SimpleNotification

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Difficulty.Utils
public LimitedCapacityStack(int capacity)
{
if (capacity < 0)
throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException(nameof(capacity));
this.capacity = capacity;
array = new T[capacity];

View File

@ -150,8 +150,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
if (HitObject.SampleControlPoint == null)
{
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
throw new InvalidOperationException($"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
}
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();

View File

@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
int repeatCount = Parsing.ParseInt(split[6]);
if (repeatCount > 9000)
throw new ArgumentOutOfRangeException(nameof(repeatCount), @"Repeat count is way too high");
throw new FormatException(@"Repeat count is way too high");
// osu-stable treated the first span of the slider as a repeat, but no repeats are happening
repeatCount = Math.Max(0, repeatCount - 1);

View File

@ -165,7 +165,7 @@ namespace osu.Game.Rulesets.Scoring
return miss;
default:
throw new ArgumentException(nameof(result));
throw new ArgumentException("Unknown enum member", nameof(result));
}
}

View File

@ -15,7 +15,7 @@ namespace osu.Game.Screens.Play
: base(() => new ReplayPlayer(score))
{
if (score.Replay == null)
throw new ArgumentNullException(nameof(score.Replay), $"{nameof(score)} must have a non-null {nameof(score.Replay)}.");
throw new ArgumentException($"{nameof(score)} must have a non-null {nameof(score.Replay)}.", nameof(score));
scoreInfo = score.ScoreInfo;
}

View File

@ -63,7 +63,7 @@ namespace osu.Game.Users
private void load(UserProfileOverlay profile)
{
if (colours == null)
throw new ArgumentNullException(nameof(colours));
throw new InvalidOperationException($"{nameof(colours)} not initialized!");
FillFlowContainer infoContainer;