CleanArchitecture.Extensions.Exceptions 0.1.6

dotnet add package CleanArchitecture.Extensions.Exceptions --version 0.1.6
                    
NuGet\Install-Package CleanArchitecture.Extensions.Exceptions -Version 0.1.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CleanArchitecture.Extensions.Exceptions" Version="0.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CleanArchitecture.Extensions.Exceptions" Version="0.1.6" />
                    
Directory.Packages.props
<PackageReference Include="CleanArchitecture.Extensions.Exceptions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CleanArchitecture.Extensions.Exceptions --version 0.1.6
                    
#r "nuget: CleanArchitecture.Extensions.Exceptions, 0.1.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CleanArchitecture.Extensions.Exceptions@0.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CleanArchitecture.Extensions.Exceptions&version=0.1.6
                    
Install as a Cake Addin
#tool nuget:?package=CleanArchitecture.Extensions.Exceptions&version=0.1.6
                    
Install as a Cake Tool

CleanArchitecture.Extensions.Exceptions

Exception catalog and MediatR pipeline behavior that standardize how Clean Architecture applications translate, log, and classify failures.

  • Base exception types with stable codes (NotFoundException, ConflictException, ForbiddenAccessException, UnauthorizedException, ConcurrencyException, TransientException, DomainException).
  • Catalog + options to map exceptions to codes, HTTP semantics, severity, and retryability while keeping handler code clean.
  • ExceptionWrappingBehavior<TRequest,TResponse> to translate unhandled exceptions into Result/Result<T> and enrich logs with correlation IDs.
  • Redaction helpers to scrub sensitive data before logging and a classifier to flag retryable/transient failures.

Install

dotnet add package CleanArchitecture.Extensions.Exceptions --version <latest-version>

Check NuGet.org for the latest stable or preview version before installing.

Usage

Register the behavior in the MediatR pipeline (after validation, before performance logging) and tune the options if needed:

using System.Net;
using CleanArchitecture.Extensions.Exceptions;
using CleanArchitecture.Extensions.Exceptions.Options;
using CleanArchitecture.Extensions.Exceptions.BaseTypes;
using CleanArchitecture.Extensions.Exceptions.Catalog;
using MediatR;

services.AddCleanArchitectureExceptions(options =>
{
    options.IncludeExceptionDetails = false;
    options.RethrowExceptionTypes.Add(typeof(OperationCanceledException));
    options.EnvironmentName = env.EnvironmentName; // include details/stack in configured environments (e.g., Development)
    options.IncludeStackTrace = false;
    options.StatusCodeOverrides["ERR.DOMAIN.GENERIC"] = HttpStatusCode.UnprocessableEntity;
});

services.AddMediatR(cfg =>
{
    cfg.RegisterServicesFromAssemblyContaining<Program>();
    cfg.AddCleanArchitectureExceptionsPipeline();
});

// Optional: configure catalog overrides
services.Configure<ExceptionCatalogOptions>(catalog =>
{
    catalog.Descriptors.Add(new ExceptionDescriptor(
        typeof(CustomDomainException),
        "ERR.DOMAIN.CUSTOM",
        "Custom domain failure",
        ExceptionSeverity.Error));
});

When handlers return Result/Result<T>, the behavior converts catalogued exceptions into failure results so controllers can return ProblemDetails consistently. Configure redaction and retry classification via ExceptionHandlingOptions and the catalog if you need stricter policies.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.