Skip to content

Commit

Permalink
Update ErrorOr.cs | removal of the second null check for errors | pri…
Browse files Browse the repository at this point in the history
…vate ErrorOr(List<Error> errors)

private ErrorOr(List<Error> errors)
{
	if (errors is null)
	{
		throw new ArgumentNullException(nameof(errors));
	}

	if (errors is null || errors.Count == 0)
	{
		throw new ArgumentException("Cannot create an ErrorOr<TValue> from an empty collection of errors. Provide at least one error.", nameof(errors));
	}

	_errors = errors;
}

This check is unnecessary due to the one performed just above.
  • Loading branch information
kebrok authored Nov 20, 2024
1 parent ff7eac7 commit 7b9fdb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ErrorOr/ErrorOr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private ErrorOr(List<Error> errors)
throw new ArgumentNullException(nameof(errors));
}

if (errors is null || errors.Count == 0)
if (errors.Count == 0)
{
throw new ArgumentException("Cannot create an ErrorOr<TValue> from an empty collection of errors. Provide at least one error.", nameof(errors));
}
Expand Down

0 comments on commit 7b9fdb1

Please sign in to comment.