diff --git a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs index e8f1f48..d689a1e 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionViewsCommand.cs @@ -24,15 +24,21 @@ public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandle foreach (var action in actions) { - var ok = await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel); - if (!ok) + try + { + await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel); + } + catch + { switch (action.ErrorAction) { case ErrorAction.Continue: break; default: - return; + // Rethrow the exception to stop processing further actions + throw; } + } } } } \ No newline at end of file diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs index 2cf7b89..d4b6aa8 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs @@ -1,12 +1,10 @@ using MediatR; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options; -using ReC.Application.Common; using ReC.Application.Common.Constants; using ReC.Application.Common.Dto; using ReC.Application.Common.Exceptions; using ReC.Application.Common.Options; -using ReC.Application.Common.Procedures.InsertProcedure; using ReC.Application.Results.Commands; using ReC.Domain.Constants; using System.Net; @@ -16,7 +14,7 @@ using System.Text.Json; namespace ReC.Application.RecActions.Commands; -public record InvokeRecActionViewCommand : IRequest +public record InvokeRecActionViewCommand : IRequest { public RecActionViewDto Action { get; set; } = null!; } @@ -26,11 +24,11 @@ public class InvokeRecActionViewCommandHandler( ISender sender, IHttpClientFactory clientFactory, IConfiguration? config = null - ) : IRequestHandler + ) : IRequestHandler { private readonly RecActionOptions _options = options.Value; - public async Task Handle(InvokeRecActionViewCommand request, CancellationToken cancel) + public async Task Handle(InvokeRecActionViewCommand request, CancellationToken cancel) { var action = request.Action; @@ -155,8 +153,6 @@ public class InvokeRecActionViewCommandHandler( Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }), Body = resBody }, cancel); - - return response.IsSuccessStatusCode; } finally {