Cayaqui.MPS.BuildingBlocks.AspNetCore 0.1.1

dotnet add package Cayaqui.MPS.BuildingBlocks.AspNetCore --version 0.1.1
                    
NuGet\Install-Package Cayaqui.MPS.BuildingBlocks.AspNetCore -Version 0.1.1
                    
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="Cayaqui.MPS.BuildingBlocks.AspNetCore" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cayaqui.MPS.BuildingBlocks.AspNetCore" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Cayaqui.MPS.BuildingBlocks.AspNetCore" />
                    
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 Cayaqui.MPS.BuildingBlocks.AspNetCore --version 0.1.1
                    
#r "nuget: Cayaqui.MPS.BuildingBlocks.AspNetCore, 0.1.1"
                    
#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 Cayaqui.MPS.BuildingBlocks.AspNetCore@0.1.1
                    
#: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=Cayaqui.MPS.BuildingBlocks.AspNetCore&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Cayaqui.MPS.BuildingBlocks.AspNetCore&version=0.1.1
                    
Install as a Cake Tool

Cayaqui.MPS.BuildingBlocks.AspNetCore

ASP.NET Core companion for Cayaqui.MPS.BuildingBlocks: mapea Result<T>/DomainError a RFC 7807 ProblemDetails por ErrorType, proporciona un IExceptionHandler global (500 + traceId) y el método de extensión AddMpsErrorHandling.

Contenido

Tipo Función
ProblemDetailsMapper StatusFor(ErrorType), ToProblemDetails(DomainError), Result<T>.ToHttpResult()
GlobalExceptionHandler DomainRuleException → ProblemDetails por ErrorType (409/400/404…); el resto → 500 + traceId
AddMpsErrorHandling Registra AddProblemDetails + AddExceptionHandler<GlobalExceptionHandler>

Setup

// Program.cs
builder.Services.AddMpsErrorHandling();

var app = builder.Build();
app.UseExceptionHandler();
app.UseStatusCodePages();

Mapa ErrorType → HTTP

ErrorType Status
Validation 400
Unauthorized 401
Forbidden 403
NotFound 404
Conflict 409
Concurrency 409
Unexpected 500

Uso en Minimal API / Controller

app.MapGet("/projects/{id}", async (Guid id, IProjectService svc) =>
{
    var result = await svc.GetAsync(id);
    return result.ToHttpResult();
});

ToHttpResult() retorna 200 OK con el valor si IsSuccess, o un ProblemDetails con el status correspondiente al ErrorType si IsFailure.

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.

Version Downloads Last Updated
0.1.1 97 6/5/2026
0.1.0 103 6/4/2026

0.1.1 — GlobalExceptionHandler ahora mapea DomainRuleException (BuildingBlocks 0.4.1) a ProblemDetails por ErrorType (Conflict→409, Validation→400, NotFound→404…) y la loguea a Debug (rechazo de negocio esperado, no 500). El resto de excepciones sigue → 500 + traceId. 0.1.0 — Initial release: ProblemDetailsMapper (ErrorType→HTTP status, DomainError→ProblemDetails, Result<T>.ToHttpResult()), GlobalExceptionHandler (unhandled exception → 500 + traceId) and AddMpsErrorHandling DI extension.