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

@ -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)
{