Refactor error handling in RecActionView invocation
Switch to exception-based error handling for invoking RecActionView actions, removing boolean return values and related checks. Update command and handler signatures to use void return type. Clean up unused using directives. This improves clarity and robustness of error management during batch processing.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user