Class DomainExceptionHandler
- Namespace
- JD.Domain.AspNetCore
- Assembly
- JD.Domain.AspNetCore.dll
IExceptionHandler implementation for DomainValidationException. Use this with .NET 8+ exception handling middleware.
public sealed class DomainExceptionHandler : IExceptionHandler
- Inheritance
-
DomainExceptionHandler
- Implements
- Inherited Members
Constructors
DomainExceptionHandler(DomainValidationOptions, ValidationProblemDetailsFactory, ILogger<DomainExceptionHandler>)
Initializes a new instance of the DomainExceptionHandler class.
public DomainExceptionHandler(DomainValidationOptions options, ValidationProblemDetailsFactory factory, ILogger<DomainExceptionHandler> logger)
Parameters
optionsDomainValidationOptionsfactoryValidationProblemDetailsFactoryloggerILogger<DomainExceptionHandler>
Methods
TryHandleAsync(HttpContext, Exception, CancellationToken)
Tries to handle the specified exception asynchronously within the ASP.NET Core pipeline. Implementations of this method can provide custom exception-handling logic for different scenarios.
public ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
Parameters
httpContextHttpContextThe HttpContext for the request.
exceptionExceptionThe unhandled exception.
cancellationTokenCancellationTokenThe cancellation token.