jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
11k stars 1.16k forks source link

IRequestExceptionHandler can not handle exceptions thrown by pipelinebehaviours #897

Closed onurguler1 closed 1 year ago

onurguler1 commented 1 year ago

Hi, in my sceneraio I have 1 exceptionhandler, 2 pipeline behaviour validation and logging. I registered them by order that I want as below: services.AddTransient(typeof(IRequestExceptionHandler<,,>), typeof(ExceptionHandlingBehaviour<,,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehaviour<,>));

When a validationException thrown by validationbehaviour, exceptionhandlingbehaviour can not handle.

github-actions[bot] commented 1 year ago

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.

jbogard commented 1 year ago

This is because the order isn't right. Exception behaviors should be the outermost ones.

jbogard commented 1 year ago

Also it doesn't look like you're using the AddMediatR method, that confuses things here. This looks like a container issue here.