Skip to content

Commit

Permalink
Rename message to errorMessage for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Exanite committed Dec 30, 2024
1 parent f702bdc commit a521a91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Utilities/AssertUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ namespace Exanite.Core.Utilities
public static class AssertUtility
{
[Conditional("DEBUG")]
public static void IsTrue([DoesNotReturnIf(false)] bool condition, string message)
public static void IsTrue([DoesNotReturnIf(false)] bool condition, string errorMessage)
{
GuardUtility.IsTrue(condition, message);
GuardUtility.IsTrue(condition, errorMessage);
}

[Conditional("DEBUG")]
public static void IsFalse([DoesNotReturnIf(true)] bool condition, string message)
public static void IsFalse([DoesNotReturnIf(true)] bool condition, string errorMessage)
{
GuardUtility.IsFalse(condition, message);
GuardUtility.IsFalse(condition, errorMessage);
}

public static T NotNull<T>(T? value, string? message = null) where T : notnull
public static T NotNull<T>(T? value, string? errorMessage = null) where T : notnull
{
#if DEBUG
GuardUtility.NotNull(value, message);
GuardUtility.NotNull(value, errorMessage);
#endif

return value!;
Expand Down
12 changes: 6 additions & 6 deletions Utilities/GuardUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ namespace Exanite.Core.Utilities
/// </remarks>
public static class GuardUtility
{
public static void IsTrue([DoesNotReturnIf(false)] bool condition, string message)
public static void IsTrue([DoesNotReturnIf(false)] bool condition, string errorMessage)
{
if (!condition)
{
throw new GuardException(message);
throw new GuardException(errorMessage);
}
}

public static void IsFalse([DoesNotReturnIf(true)] bool condition, string message)
public static void IsFalse([DoesNotReturnIf(true)] bool condition, string errorMessage)
{
if (condition)
{
throw new GuardException(message);
throw new GuardException(errorMessage);
}
}

public static T NotNull<T>(T? value, string? message = null) where T : notnull
public static T NotNull<T>(T? value, string? errorMessage = null) where T : notnull
{
IsTrue(value != null, message ?? "Value was null");
IsTrue(value != null, errorMessage ?? "Value was null");

return value;
}
Expand Down

0 comments on commit a521a91

Please sign in to comment.