DcsvIo.D2.ErrorCodes.Registry 0.1.1

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

DcsvIo.D2.ErrorCodes.Registry

Merged cross-catalog error-code registry for D2. Aggregates every *-error-codes.spec.json catalog into a single compile-time-frozen code → ErrorCodeInfo lookup table — so any consuming service can resolve a wire error code to its full metadata without importing the producer's catalog.

Generated by DcsvIo.D2.ErrorCodes.Registry.SourceGen (RegistryGenerator) from the generic error-codes catalog plus all domain *-error-codes.spec.json files. Never hand-edit generated ErrorCodeRegistry.g.cs — change the spec and rebuild.

Install

dotnet add package DcsvIo.D2.ErrorCodes.Registry

Public API

Member Kind Description
ErrorCodeInfo readonly record struct (8 fields) Full metadata record for one error code — see field table below.
ErrorCodeRegistry.TryResolve(code, out info) static bool Looks up code in the frozen dictionary; writes ErrorCodeInfo on hit and returns true; returns false on miss.
ErrorCodeRegistry.Resolve(code) static ErrorCodeInfo? Returns ErrorCodeInfo on hit; returns null on unknown code (never throws).
ErrorCodeRegistry.All static IReadOnlyCollection<ErrorCodeInfo> All registered entries in spec-declaration order.
if (ErrorCodeRegistry.TryResolve("AUTH_JWT_EXPIRED", out var info))
{
    info.Code;           // "AUTH_JWT_EXPIRED"
    info.HttpStatus;     // 401
    info.Category;       // ErrorCategory.ValidationFailure
    info.Category.ToWire(); // "validation_failure"
    info.UserMessageKey; // TK.Auth.Errors.UNAUTHORIZED
    info.FactoryName;    // "JwtExpired"
    info.FactoryShape;   // "standard"
    info.Domain;         // "auth"
}

var allCodes = ErrorCodeRegistry.All;

ErrorCodeInfo field shape

Field Type Source
Code string SCREAMING_SNAKE wire code (e.g. AUTH_JWT_EXPIRED)
HttpStatus int HTTP status integer (e.g. 401, 404)
Category ErrorCategory Closed nine-value enum from DcsvIo.D2.ErrorCodes.Category; serializes as snake_case wire string via ErrorCategoryJsonConverter
UserMessageKey TKMessage Typed TK constant; callers needing the wire key read .Key
FactoryName string PascalCase factory symbol (e.g. BearerMissing)
FactoryShape string One of standard (the universal error-factory shape) / none
Doc string Developer documentation text from the spec
Domain string Derived from spec filename: common (generic catalog), auth, etc.

Catalog behavior

  • Merged: all *-error-codes.spec.json catalogs are aggregated into one registry at build time — no runtime I/O or DI required.
  • Cross-catalog collision guard: D2ERC004 fires at build time when the same code string appears in two different catalogs; D2ERC005 fires on reserved-namespace violations (unprefixed code in a per-domain spec, or domain-prefixed code in the generic spec). No registry is emitted until violations are resolved.
  • Category validation: D2ERC006 fires on a malformed spec; D2ERC007 fires when a code's category wire string is not a member of the closed ErrorCategory set.
  • Unknown codes return false / null — a hard not-found signaling deploy-skew to the caller.

Dependency edges

DcsvIo.D2.ErrorCodes.Category   (zero-dep leaf — ErrorCategory enum)
         ▲
         └── DcsvIo.D2.ErrorCodes.Registry
                   ▲
                   └── (consuming services — never from domain code)

DcsvIo.D2.I18n.Keys is also a direct dependency (the UserMessageKey field is a typed TKMessage; the TKMessage constructor is internal and DcsvIo.D2.I18n.Abstractions grants InternalsVisibleTo access to this assembly).

Source of truth

Generic error-codes catalog + every domain *-error-codes.spec.json + the closed error-category set the registry cross-checks against at codegen time.

The TypeScript package @dcsv-io/d2-error-codes-registry is generated from the same spec set. Cross-runtime parity is pinned by shared fixtures / twin tests.

Product 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. 
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
0.1.1 103 7/17/2026
0.1.0 105 7/17/2026