mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Standardise usages of exceptions.
This commit is contained in:
@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays
|
|||||||
{
|
{
|
||||||
public int Compare(ReplayFrame f1, ReplayFrame f2)
|
public int Compare(ReplayFrame f1, ReplayFrame f2)
|
||||||
{
|
{
|
||||||
if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null");
|
if (f1 == null) throw new ArgumentNullException(nameof(f1));
|
||||||
if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null");
|
if (f2 == null) throw new ArgumentNullException(nameof(f2));
|
||||||
|
|
||||||
return f1.Time.CompareTo(f2.Time);
|
return f1.Time.CompareTo(f2.Time);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
|||||||
Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
|
Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
|
||||||
}
|
}
|
||||||
else
|
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));
|
Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));
|
||||||
|
|
||||||
|
@ -94,13 +94,13 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
byte[] properties = new byte[5];
|
byte[] properties = new byte[5];
|
||||||
if (replayInStream.Read(properties, 0, 5) != 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;
|
long outSize = 0;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
int v = replayInStream.ReadByte();
|
int v = replayInStream.ReadByte();
|
||||||
if (v < 0)
|
if (v < 0)
|
||||||
throw new Exception("Can't Read 1");
|
throw new IOException("Can't Read 1");
|
||||||
outSize |= (long)(byte)v << (8 * i);
|
outSize |= (long)(byte)v << (8 * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Graphics
|
|||||||
switch (hex.Length)
|
switch (hex.Length)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
throw new Exception(@"Invalid hex string length!");
|
throw new ArgumentException(@"Invalid hex string length!");
|
||||||
case 3:
|
case 3:
|
||||||
return new Color4(
|
return new Color4(
|
||||||
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),
|
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),
|
||||||
|
@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
|
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BeatmapInvalidForRulesetException : Exception
|
public class BeatmapInvalidForRulesetException : ArgumentException
|
||||||
{
|
{
|
||||||
public BeatmapInvalidForRulesetException(string text)
|
public BeatmapInvalidForRulesetException(string text)
|
||||||
: base(text)
|
: base(text)
|
||||||
|
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
|
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
|
||||||
|
|
||||||
if (Beatmap?.Beatmap == null)
|
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;
|
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
|
||||||
rulesetInstance = ruleset.CreateInstance();
|
rulesetInstance = ruleset.CreateInstance();
|
||||||
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!HitRenderer.Objects.Any())
|
if (!HitRenderer.Objects.Any())
|
||||||
throw new Exception("Beatmap contains no hit objects!");
|
throw new InvalidOperationException("Beatmap contains no hit objects!");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user