diff --git a/SpookilySharp/ExceptionHelper.cs b/SpookilySharp/ExceptionHelper.cs index c4127f0..5a7abb2 100644 --- a/SpookilySharp/ExceptionHelper.cs +++ b/SpookilySharp/ExceptionHelper.cs @@ -31,22 +31,22 @@ public static void CheckNotNull(object arg, string name) public static void CheckNotNullString(string arg) => CheckNotNull(arg, "s"); - public static void BadHashCode128Format() => - throw new FormatException("The string did not contain a 32-digit hexadecimal number."); + public static Exception BadHashCode128Format() => + new FormatException("The string did not contain a 32-digit hexadecimal number."); - private static void StartIndexOutOfRange() => throw new ArgumentOutOfRangeException("startIndex"); + private static Exception StartIndexOutOfRange() => new ArgumentOutOfRangeException("startIndex"); - private static void NegativeLength() => throw new ArgumentOutOfRangeException("length"); + private static Exception NegativeLength() => new ArgumentOutOfRangeException("length"); - private static void PastArrayBounds() => throw new ArgumentException("Attempt to read beyond the end of the array."); + private static Exception PastArrayBounds() => new ArgumentException("Attempt to read beyond the end of the array."); - private static void PastStringBounds() => throw new ArgumentException("Attempt to read beyond the end of the string."); + private static Exception PastStringBounds() => new ArgumentException("Attempt to read beyond the end of the string."); private static void CheckNotNegativeLength(int length) { if (length < 0) { - NegativeLength(); + throw NegativeLength(); } } @@ -54,7 +54,7 @@ private static void CheckIndexInRange(int startIndex, int length) { if ((uint)startIndex >= (uint)length) { - StartIndexOutOfRange(); + throw StartIndexOutOfRange(); } } @@ -65,7 +65,7 @@ public static void CheckArray(T[] message, int startIndex, int length) CheckIndexInRange(startIndex, len); if (startIndex + length > len) { - PastArrayBounds(); + throw PastArrayBounds(); } } @@ -82,7 +82,7 @@ public static void CheckBounds(string message, int startIndex, int length) CheckIndexInRange(startIndex, len); if (startIndex + length > len) { - PastStringBounds(); + throw PastStringBounds(); } } diff --git a/SpookilySharp/HashCode128.cs b/SpookilySharp/HashCode128.cs index 9a67d61..2c4143c 100644 --- a/SpookilySharp/HashCode128.cs +++ b/SpookilySharp/HashCode128.cs @@ -220,7 +220,7 @@ public static HashCode128 Parse(string s) ExceptionHelper.CheckNotNullString(s); if (!TryParse(s, out HashCode128 ret)) { - ExceptionHelper.BadHashCode128Format(); + throw ExceptionHelper.BadHashCode128Format(); } return ret;