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
<PackageReference Include="CleanArchitecture.Extensions.Exceptions" Version="0.1.6" />
<PackageVersion Include="CleanArchitecture.Extensions.Exceptions" Version="0.1.6" />
<PackageReference Include="CleanArchitecture.Extensions.Exceptions" />
paket add CleanArchitecture.Extensions.Exceptions --version 0.1.6
#r "nuget: CleanArchitecture.Extensions.Exceptions, 0.1.6"
#:package CleanArchitecture.Extensions.Exceptions@0.1.6
#addin nuget:?package=CleanArchitecture.Extensions.Exceptions&version=0.1.6
#tool nuget:?package=CleanArchitecture.Extensions.Exceptions&version=0.1.6
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 intoResult/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 | Versions 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. |
-
net10.0
- CleanArchitecture.Extensions.Core (>= 0.1.6)
- MediatR (>= 14.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.1.6 | 446 | 12/10/2025 | |
| 0.1.6-preview.13 | 394 | 12/10/2025 | |
| 0.1.5 | 457 | 12/9/2025 | |
| 0.1.4 | 448 | 12/9/2025 | |
| 0.1.3-preview.1 | 385 | 12/8/2025 |