Class RequestExceptionProcessorBehavior<TRequest, TResponse>
Catches exceptions from the inner pipeline and dispatches them to the matching IRequestExceptionHandler<TRequest, TResponse, TException> instances, most specific exception type first. If a handler marks the exception as handled, its response is returned; otherwise the exception is rethrown with its original stack trace.
public sealed class RequestExceptionProcessorBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
Type Parameters
TRequestThe request type.
TResponseThe response type.
- Inheritance
-
RequestExceptionProcessorBehavior<TRequest, TResponse>
- Implements
-
IPipelineBehavior<TRequest, TResponse>
- Inherited Members
Constructors
RequestExceptionProcessorBehavior(IServiceProvider)
Creates the behavior.
public RequestExceptionProcessorBehavior(IServiceProvider serviceProvider)
Parameters
serviceProviderIServiceProviderProvider used to resolve exception handlers.
Methods
Handle(TRequest, RequestHandlerDelegate<TResponse>, CancellationToken)
Handles the request, calling next to continue the pipeline.
public Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
Parameters
requestTRequestThe request.
nextRequestHandlerDelegate<TResponse>Continues the pipeline. Not calling it short-circuits the request.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TResponse>