ErrorApi.ArdalisResult
1.0.1
dotnet add package ErrorApi.ArdalisResult --version 1.0.1
NuGet\Install-Package ErrorApi.ArdalisResult -Version 1.0.1
<PackageReference Include="ErrorApi.ArdalisResult" Version="1.0.1" />
<PackageVersion Include="ErrorApi.ArdalisResult" Version="1.0.1" />
<PackageReference Include="ErrorApi.ArdalisResult" />
paket add ErrorApi.ArdalisResult --version 1.0.1
#r "nuget: ErrorApi.ArdalisResult, 1.0.1"
#:package ErrorApi.ArdalisResult@1.0.1
#addin nuget:?package=ErrorApi.ArdalisResult&version=1.0.1
#tool nuget:?package=ErrorApi.ArdalisResult&version=1.0.1

ErrorApi.ArdalisResult
Maps Ardalis.Result onto Minimal API results and ErrorApi's
documented error catalog: every endpoint's OpenAPI document lists the failures it can actually return,
and the wire response carries a stable machine-readable code — resolved at compile time by the
ErrorApi source generator, with no reflection at runtime.
dotnet add package ErrorApi.ArdalisResult
The package brings the generator with it (PrivateAssets="none"), so referencing the adapter is the
whole setup.
Before
Ardalis.Result maps failures to responses at runtime — typically through Ardalis.Result.AspNetCore's
ToActionResult — so the OpenAPI document never learns about them:
public Result<Order> GetById(Guid id) =>
_orders.TryGetValue(id, out var order) ? order : Result.NotFound();
app.MapGet("/orders/{id:guid}", (Guid id, IOrderService s) => s.GetById(id).ToMinimalApiResult());
// Document: 200 OK. The 404 exists — the frontend meets it in production.
// The body is whatever the mapper improvises; there is no stable code to switch on.
After
Ardalis has no typed error and no code slot of its own, so the identity lives in a catalog of factory
members — the code carried where Ardalis has room for it, an error message or
ValidationError.ErrorCode, and the [Error] attribute tying it to a status and title:
[ErrorCatalog("Orders")]
public static class OrderErrors
{
[ErrorApi.Error("Orders.NotFound", 404, Title = "Order not found")]
public static Result NotFound() => Result.NotFound("Orders.NotFound");
[ErrorApi.Error("Orders.InvalidCustomer", 400, Title = "Customer must not be empty")]
public static Result InvalidCustomer() => Result.Invalid(new ValidationError
{
ErrorCode = "Orders.InvalidCustomer",
ErrorMessage = "Customer must not be empty.",
});
}
public Result<Order> GetById(Guid id) =>
_orders.TryGetValue(id, out var order) ? order : OrderErrors.NotFound();
builder.Services.AddErrorApi();
app.MapGet("/orders/{id:guid}", (Guid id, IOrderService s) => s.GetById(id).ToHttpResult());
// Document: 200 + 404 with code "Orders.NotFound", title, and an example body.
// Wire: { "title": "Order not found", "status": 404, "code": "Orders.NotFound" }
The generator follows the handler into the service and its implementation, sees the factory in the call graph, and documents the endpoint — nothing is declared at the call site.
How a failure resolves at runtime
- A
ValidationError.ErrorCodethe catalog knows — status, title and code come from the declaration the document was built from; the validation message becomesdetail. - An error message that is a known code — same treatment.
- Neither: the
ResultStatussupplies the HTTP status (the same mappingArdalis.Result.AspNetCoreuses —Invalid400,Error422,CriticalError500) and its name becomes the code. That is a deliberately weak contract: a failure without a catalog identity cannot be promised in a document.
Success statuses keep their Ardalis meaning: Ok → 200 with the value, Created → 201 with the
result's Location, NoContent → 204.
Versions
Pinned to the Ardalis.Result version in this repository's Directory.Packages.props; the test suite
also runs against older releases in CI (-p:ArdalisResultTestVersion=x.y.z).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Ardalis.Result (>= 10.1.0)
- ErrorApi.AspNetCore (>= 1.0.1)
- Microsoft.AspNetCore.OpenApi (>= 10.0.11)
-
net8.0
- Ardalis.Result (>= 10.1.0)
- ErrorApi.AspNetCore (>= 1.0.1)
-
net9.0
- Ardalis.Result (>= 10.1.0)
- ErrorApi.AspNetCore (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.