Closed VictorioBerra closed 8 months ago
I think I am way out of my depth here. This fixes it, and I have no idea why:
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssemblies(this.GetType().Assembly);
cfg.AddOpenRequestPostProcessor(typeof(StepRecorderingRequestPostProcessor<,>));
cfg.AddOpenBehavior(typeof(KeepGoinRequestExceptionProcessorBehavior<,>));
});
public class KeepGoinRequestExceptionProcessorBehavior<TRequest, TResponse> : RequestExceptionProcessorBehavior<TRequest, TResponse>
{
public KeepGoinRequestExceptionProcessorBehavior(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
public async Task<TResponse> HandleAsync(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
{
throw new Exception("Here we go");
}
}
Working repro: https://dotnetfiddle.net/WWjl80
@jbogard any ideas on this one?
I'm not sure what's "correct" here. But you can always create your own behaviors that wrap the exception behavior. Unfortunately there's no right or wrong here, other than adding more pre/post processors. "Pre/PostException" etc.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
Repro:
https://dotnetfiddle.net/AvoV1L
For me this is important because I would expect my post processor to wrap up auditing, close transactions, etc. This does not happen even though the exception is explicitly handled and a result is returned.