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
<PackageReference Include="DcsvIo.D2.ErrorCodes.Registry" Version="0.1.1" />
<PackageVersion Include="DcsvIo.D2.ErrorCodes.Registry" Version="0.1.1" />
<PackageReference Include="DcsvIo.D2.ErrorCodes.Registry" />
paket add DcsvIo.D2.ErrorCodes.Registry --version 0.1.1
#r "nuget: DcsvIo.D2.ErrorCodes.Registry, 0.1.1"
#:package DcsvIo.D2.ErrorCodes.Registry@0.1.1
#addin nuget:?package=DcsvIo.D2.ErrorCodes.Registry&version=0.1.1
#tool nuget:?package=DcsvIo.D2.ErrorCodes.Registry&version=0.1.1
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.jsoncatalogs are aggregated into one registry at build time — no runtime I/O or DI required. - Cross-catalog collision guard:
D2ERC004fires at build time when the same code string appears in two different catalogs;D2ERC005fires 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:
D2ERC006fires on a malformed spec;D2ERC007fires when a code'scategorywire string is not a member of the closedErrorCategoryset. - 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 | 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
- DcsvIo.D2.ErrorCodes.Category (>= 0.1.1)
- DcsvIo.D2.I18n.Keys (>= 0.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.