1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Standardise usages of exceptions.

This commit is contained in:
Huo Yaoyuan 2017-05-07 00:38:17 +08:00
parent 91ad0cb75e
commit 4f8549f220
6 changed files with 9 additions and 9 deletions

View File

@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays
{
public int Compare(ReplayFrame f1, ReplayFrame f2)
{
if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null");
if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null");
if (f1 == null) throw new ArgumentNullException(nameof(f1));
if (f2 == null) throw new ArgumentNullException(nameof(f2));
return f1.Time.CompareTo(f2.Time);
}

View File

@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
}
else
throw new Exception("Unknown hit object type.");
throw new InvalidOperationException("Unknown hit object type.");
Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));

View File

@ -94,13 +94,13 @@ namespace osu.Game.Database
{
byte[] properties = new byte[5];
if (replayInStream.Read(properties, 0, 5) != 5)
throw new Exception("input .lzma is too short");
throw new IOException("input .lzma is too short");
long outSize = 0;
for (int i = 0; i < 8; i++)
{
int v = replayInStream.ReadByte();
if (v < 0)
throw new Exception("Can't Read 1");
throw new IOException("Can't Read 1");
outSize |= (long)(byte)v << (8 * i);
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics
switch (hex.Length)
{
default:
throw new Exception(@"Invalid hex string length!");
throw new ArgumentException(@"Invalid hex string length!");
case 3:
return new Color4(
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),

View File

@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.UI
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
}
public class BeatmapInvalidForRulesetException : Exception
public class BeatmapInvalidForRulesetException : ArgumentException
{
public BeatmapInvalidForRulesetException(string text)
: base(text)

View File

@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
if (Beatmap?.Beatmap == null)
throw new Exception("Beatmap was not loaded");
throw new InvalidOperationException("Beatmap was not loaded");
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance();
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
}
if (!HitRenderer.Objects.Any())
throw new Exception("Beatmap contains no hit objects!");
throw new InvalidOperationException("Beatmap contains no hit objects!");
}
catch (Exception e)
{