Skip to content

Commit 92c632d

Browse files
committed
Add CodeExceptions.ArgumentNegative
1 parent a37a447 commit 92c632d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CodeJam.Main/Assertions/CodeExceptions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ public static ArgumentOutOfRangeException ArgumentOutOfRange<T>(
154154
.LogToCodeTraceSourceBeforeThrow();
155155
}
156156

157+
/// <summary>Creates <see cref="ArgumentOutOfRangeException"/> for an argument that must be positive.</summary>
158+
/// <param name="argumentName">Name of the argument.</param>
159+
/// <returns>Initialized instance of <see cref="ArgumentOutOfRangeException"/>.</returns>
160+
[DebuggerHidden, MustUseReturnValue]
161+
public static ArgumentOutOfRangeException ArgumentNegative([InvokerParameterName] string argumentName)
162+
{
163+
BreakIfAttached();
164+
return
165+
new ArgumentOutOfRangeException(
166+
argumentName,
167+
$"The value of {argumentName} must be positive")
168+
.LogToCodeTraceSourceBeforeThrow();
169+
}
170+
157171
/// <summary>Creates <see cref="IndexOutOfRangeException"/>.</summary>
158172
/// <param name="argumentName">Name of the argument.</param>
159173
/// <param name="value">The value.</param>

0 commit comments

Comments
 (0)