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
<PackageReference Include="Cayaqui.MPS.BuildingBlocks.AspNetCore" Version="0.1.1" />
<PackageVersion Include="Cayaqui.MPS.BuildingBlocks.AspNetCore" Version="0.1.1" />
<PackageReference Include="Cayaqui.MPS.BuildingBlocks.AspNetCore" />
paket add Cayaqui.MPS.BuildingBlocks.AspNetCore --version 0.1.1
#r "nuget: Cayaqui.MPS.BuildingBlocks.AspNetCore, 0.1.1"
#:package Cayaqui.MPS.BuildingBlocks.AspNetCore@0.1.1
#addin nuget:?package=Cayaqui.MPS.BuildingBlocks.AspNetCore&version=0.1.1
#tool nuget:?package=Cayaqui.MPS.BuildingBlocks.AspNetCore&version=0.1.1
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 | 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
- Cayaqui.MPS.BuildingBlocks (>= 0.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.