ResultToProblem 1.0.1
See the version list below for details.
dotnet add package ResultToProblem --version 1.0.1
NuGet\Install-Package ResultToProblem -Version 1.0.1
<PackageReference Include="ResultToProblem" Version="1.0.1" />
<PackageVersion Include="ResultToProblem" Version="1.0.1" />
<PackageReference Include="ResultToProblem" />
paket add ResultToProblem --version 1.0.1
#r "nuget: ResultToProblem, 1.0.1"
#:package ResultToProblem@1.0.1
#addin nuget:?package=ResultToProblem&version=1.0.1
#tool nuget:?package=ResultToProblem&version=1.0.1
ResultToProblem
https://www.nuget.org/packages/ResultToProblem/
ResultToProblem is a .NET library that extends the Result pattern and simplifies the conversion of domain results into standard HTTP responses using ProblemDetails.
Its purpose is to streamline error handling in ASP.NET Core applications, maintaining a clean and consistent style across endpoints and controllers.
Installation
Install the package from NuGet:
bash dotnet add package ResultToProblem
Usage
Examples in an ASP.NET Core project:
app.MapGet("/weather", () ⇒ { var random = new Random(); var temperature = random.Next(-10, 40);
if (temperature < -5)
{
return Result.Failure<string>(
Error.Unexpected("Weather.Service", "Temperature sensor error")
).ToProblemDetails();
}
return Result.Success($"Today's temperature is {temperature}°C");
});
app.MapGet("/user/{id}", (int id) ⇒ { if (id ⇐ 0) { // Using the Validation factory method return Result.Failure<string>( Error.Validation("USER_ID_INVALID", "The user ID must be greater than zero") ).ToProblemDetails(); }
if (id == 404)
{
// Using the NotFound factory method
return Result.Failure<string>(
Error.NotFound("USER_NOT_FOUND", $"User with ID {id} was not found")
).ToProblemDetails();
}
if (id == 500)
{
// Using the Unexpected factory method
return Result.Failure<string>(
Error.Unexpected("USER_SERVICE_ERROR", "Unexpected error occurred while fetching user")
).ToProblemDetails();
}
// Success case
return Result.Success($"User {id} retrieved successfully");
});
✨ Features
- Automatically converts Result objects into ProblemDetails
- Standardized handling for common errors: NotFound, Validation, Conflict, Unexpected
- Easy-to-use extensions for minimal API endpoints
- Compatible with Clean Architecture and Domain-Driven Design
📦 Publishing
This project is distributed as a NuGet package.
To publish a new version:
bash dotnet build -c Release dotnet pack -c Release dotnet nuget push bin/Release/ResultToProblem.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json
⚖️ License
This project is freely available under the MIT license.
You may use, modify, and distribute it without restrictions, as long as you retain the reference to the original license.
| 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
- Microsoft.AspNetCore.Http (>= 2.3.9)
- Microsoft.AspNetCore.OpenApi (>= 10.0.7)
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 |
|---|---|---|
| 2.0.7 | 148 | 6/14/2026 |
| 2.0.6 | 112 | 5/13/2026 |
| 2.0.5 | 105 | 5/13/2026 |
| 2.0.4 | 107 | 5/13/2026 |
| 2.0.3 | 107 | 5/13/2026 |
| 2.0.2 | 108 | 5/12/2026 |
| 2.0.1 | 107 | 5/12/2026 |
| 2.0.0 | 109 | 5/12/2026 |
| 1.0.9 | 117 | 5/12/2026 |
| 1.0.8 | 105 | 5/11/2026 |
| 1.0.7 | 116 | 5/11/2026 |
| 1.0.6 | 108 | 5/11/2026 |
| 1.0.5 | 103 | 5/11/2026 |
| 1.0.4 | 116 | 5/8/2026 |
| 1.0.3 | 122 | 5/8/2026 |
| 1.0.2 | 109 | 5/8/2026 |
| 1.0.1 | 108 | 5/8/2026 |
| 1.0.0 | 112 | 5/8/2026 |