Table of Contents

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

options DomainValidationOptions
factory ValidationProblemDetailsFactory
logger ILogger<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

httpContext HttpContext

The HttpContext for the request.

exception Exception

The unhandled exception.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<bool>

A task that represents the asynchronous read operation. The value of its Result property contains the result of the handling operation. true if the exception was handled successfully; otherwise false.