ErrorApi 1.0.1

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

ErrorApi

ErrorApi

Start here. One package: the source generator, the Error/Result primitives and the ASP.NET Core integration — so the OpenAPI document lists every failure each endpoint can actually return, and the response body always matches it.

dotnet add package ErrorApi

That is the whole install. This is a meta-package: it carries no code of its own, only ErrorApi.AspNetCore (which ships the generator and the primitives) — and on .NET 8/9 also ErrorApi.Swashbuckle, because there the document has to come through Swagger.

Quickstart

1. Declare the catalog — the class declares membership and the default status, the members declare the names; the generator writes the bodies and infers the codes:

[ErrorCatalog("Orders", StatusCodes.Status404NotFound)]
public static partial class OrderErrors
{
    public static partial Error NotFound { get; }                              // Orders.NotFound, 404

    [Error(StatusCodes.Status409Conflict, Detail = "Order {0} was already paid.")]
    public static partial Error AlreadyPaid(Guid orderId);                     // Orders.AlreadyPaid, 409
}

2. Return the entriesError converts implicitly into Result<T>:

public Result<Order> GetById(Guid id) =>
    _orders.TryGetValue(id, out var order) ? order : OrderErrors.NotFound;

3. Wire it up onceAddErrorApi() is the whole minimal setup:

builder.Services.AddOpenApi();
builder.Services.AddErrorApi();

app.MapGet("/orders/{id:guid}", (Guid id, IOrderService s) => s.GetById(id).ToHttpResult());

On .NET 8/9 swap the first line for Swagger — the filter is already in the box:

builder.Services.AddSwaggerGen(c => c.AddErrorApiResponses());
builder.Services.AddErrorApi();

One more thing there: partial properties like NotFound above are a C# 13 feature, so a net8/net9 project sets <LangVersion>latest</LangVersion> — or declares its entries as partial methods, which every C# the packages support can compile.

The generator walks each handler through the call graph, works out which catalog entries it can reach, and emits a reflection-free model. The document gains one response per status with every reachable code listed and an example problem body; at runtime the same model maps each failure to application/problem+json carrying that code — native-AOT clean, nothing decided on the request path.

When to reach past this package

Package Take it when
ErrorApi.Abstractions a class library only declares catalog entries — attributes and primitives, no ASP.NET Core
ErrorApi.AspNetCore you want exactly the integration and nothing else picking dependencies for you
ErrorApi.Swashbuckle a .NET 10 project stays on Swagger (on net8/net9 this package already brings it)
ErrorApi.ErrorOr, .OneOf, .LanguageExt, .FluentResults, .ArdalisResult, .CSharpFunctionalExtensions you already use that result library — keep your types, often a bare [Error] is the entire onboarding

Full documentation

github.com/SideswipeN7/ErrorApi — how discovery works, the EAPI001EAPI013 diagnostics, the TypeScript error contract, and the result-library adapters.

There are no supported framework assets in this 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 86 8/31/2026