From 7b9fdb19e265e98bbfc67ac84bf4e989baddee76 Mon Sep 17 00:00:00 2001 From: kebrok <68332676+kebrok@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:13:47 +0100 Subject: [PATCH] Update ErrorOr.cs | removal of the second null check for errors | private ErrorOr(List errors) private ErrorOr(List errors) { if (errors is null) { throw new ArgumentNullException(nameof(errors)); } if (errors is null || errors.Count == 0) { throw new ArgumentException("Cannot create an ErrorOr 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. --- src/ErrorOr/ErrorOr.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ErrorOr/ErrorOr.cs b/src/ErrorOr/ErrorOr.cs index b958157..b782533 100644 --- a/src/ErrorOr/ErrorOr.cs +++ b/src/ErrorOr/ErrorOr.cs @@ -32,7 +32,7 @@ private ErrorOr(List errors) throw new ArgumentNullException(nameof(errors)); } - if (errors is null || errors.Count == 0) + if (errors.Count == 0) { throw new ArgumentException("Cannot create an ErrorOr from an empty collection of errors. Provide at least one error.", nameof(errors)); }