ErrorApi.ArdalisResult 1.0.1

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

ErrorApi

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

  1. A ValidationError.ErrorCode the catalog knows — status, title and code come from the declaration the document was built from; the validation message becomes detail.
  2. An error message that is a known code — same treatment.
  3. Neither: the ResultStatus supplies the HTTP status (the same mapping Ardalis.Result.AspNetCore uses — Invalid 400, Error 422, CriticalError 500) 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 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. 
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
1.0.1 97 8/31/2026
1.0.0 87 8/30/2026