From 938621d74db3d78079297abf476c55cf6c0b82be Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 17 Jan 2023 21:43:17 +0100 Subject: [PATCH] fix(game): make aggregate error only for errors, not successful results in event dispatcher --- Core/NosSmooth.Game/Events/Core/EventDispatcher.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/NosSmooth.Game/Events/Core/EventDispatcher.cs b/Core/NosSmooth.Game/Events/Core/EventDispatcher.cs index 06584a9eb08afcb4aeed9e3b971ab90783f2b10a..6978e9c15648b5630d7007a2007b543025d6359d 100644 --- a/Core/NosSmooth.Game/Events/Core/EventDispatcher.cs +++ b/Core/NosSmooth.Game/Events/Core/EventDispatcher.cs @@ -62,11 +62,16 @@ public class EventDispatcher ) ); - return results.Length switch + var errors = results + .Where(x => !x.IsSuccess) + .Cast() + .ToArray(); + + return errors.Length switch { 0 => Result.FromSuccess(), - 1 => results[0], - _ => new AggregateError(results.Cast().ToArray()), + 1 => (Result)errors[0], + _ => new AggregateError(errors), }; } } \ No newline at end of file