Kodster.Results.AspNetCore
0.1.0
dotnet add package Kodster.Results.AspNetCore --version 0.1.0
NuGet\Install-Package Kodster.Results.AspNetCore -Version 0.1.0
<PackageReference Include="Kodster.Results.AspNetCore" Version="0.1.0" />
<PackageVersion Include="Kodster.Results.AspNetCore" Version="0.1.0" />
<PackageReference Include="Kodster.Results.AspNetCore" />
paket add Kodster.Results.AspNetCore --version 0.1.0
#r "nuget: Kodster.Results.AspNetCore, 0.1.0"
#:package Kodster.Results.AspNetCore@0.1.0
#addin nuget:?package=Kodster.Results.AspNetCore&version=0.1.0
#tool nuget:?package=Kodster.Results.AspNetCore&version=0.1.0
Kodster.Results.AspNetCore
Turns a failed Kodster.Results Result into
an RFC 7807 ProblemDetails response.
dotnet add package Kodster.Results.AspNetCore
Depends on Kodster.Results and the ASP.NET Core shared framework. Targets .NET 10.
Usage
One extension method, ToProblemDetails(), on any Result:
app.MapGet("users/{id:guid}", async (
Guid id,
IUserService users,
CancellationToken cancellationToken) =>
{
var result = await users.Find(id, cancellationToken);
return result.IsSuccess
? Results.Ok(result.Value)
: result.ToProblemDetails();
});
Calling it on a successful result throws InvalidOperationException — it is only ever the
failure branch.
Status mapping
The ErrorType on the error decides the status code, title and type URI:
ErrorType |
Status | Title |
|---|---|---|
Validation |
400 | Bad Request |
Unauthorized |
401 | Unauthorized |
PaymentRequired |
402 | Payment Required |
Forbidden |
403 | Forbidden |
NotFound |
404 | Not Found |
Conflict |
409 | Conflict |
Gone |
410 | Gone |
PreconditionFailed |
412 | Precondition Failed |
Failure |
500 | Internal Server Error |
The type field links to the relevant RFC section for the status code.
The errors member
Every response carries an errors extension member, so clients read failures from one place
regardless of how many there were.
A plain failure carries its single error:
{
"type": "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4",
"title": "Not Found",
"status": 404,
"errors": [
{ "code": "User.NotFound", "description": "User was not found.", "type": 3 }
]
}
A ValidationResult carries all of them:
{
"type": "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"errors": [
{ "code": "Nickname", "description": "Nickname is required.", "type": 1 },
{ "code": "Age", "description": "Age must be 13 or older.", "type": 1 }
]
}
Note that type inside an error is the ErrorType ordinal, not a string. Clients that
switch on it are coupled to those numbers, which is why ErrorType only ever gains members by
appending.
Companion packages
- Kodster.Results — the
ResultandErrortypes this maps from. No dependencies. - Kodster.CQRS — request/handler abstraction whose handlers return those results.
License
MIT
| 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
- Kodster.Results (>= 0.1.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.0 | 111 | 8/19/2026 |