ApricotFramework.ErrorDefinitions
0.1.0
Prefix Reserved
dotnet add package ApricotFramework.ErrorDefinitions --version 0.1.0
NuGet\Install-Package ApricotFramework.ErrorDefinitions -Version 0.1.0
<PackageReference Include="ApricotFramework.ErrorDefinitions" Version="0.1.0" />
<PackageVersion Include="ApricotFramework.ErrorDefinitions" Version="0.1.0" />
<PackageReference Include="ApricotFramework.ErrorDefinitions" />
paket add ApricotFramework.ErrorDefinitions --version 0.1.0
#r "nuget: ApricotFramework.ErrorDefinitions, 0.1.0"
#:package ApricotFramework.ErrorDefinitions@0.1.0
#addin nuget:?package=ApricotFramework.ErrorDefinitions&version=0.1.0
#tool nuget:?package=ApricotFramework.ErrorDefinitions&version=0.1.0
ApricotFramework.ErrorDefinitions
One error contract for a fleet of services: throw a classified error anywhere, and every service and client reads the same RFC 9457 problem document back — including when the peer is not one of yours.
ApricotFramework.ErrorDefinitions is the zero-dependency core.
Install
dotnet add package ApricotFramework.ErrorDefinitions
dotnet add package ApricotFramework.ErrorDefinitions.AspNetCore
Usage
using ApricotFramework.ErrorDefinitions.AspNetCore.Extensions;
builder.Services.AddErrorDefinitions(); // nothing to configure
app.UseExceptionHandler();
// Throwing: the kind decides the status, the code decides the text a client shows.
var author = Ensure.Found(await repository.Get(id), ContentErrors.AuthorNotFound);
throw Err.Validation(ContentErrors.InvalidLocale, payload: new Dictionary<string, object?>
{
["locale"] = locale, // the client renders its own message from the code and these
}).AsException();
// Reporting several at once, so a caller fixing a form submits it once.
new ErrorCollector()
.AddIf(string.IsNullOrWhiteSpace(input.Name), Err.Validation(ContentErrors.InvalidName))
.AddIf(!input.Email.Contains('@'), Err.Validation(ContentErrors.InvalidEmail))
.ThrowIfAny();
// What the caller receives — application/problem+json
{
"type": "about:blank",
"title": "Validation failed",
"status": 400,
"detail": "That locale is not published.",
"instance": "/api/content",
"errors": [
{ "kind": "validation", "code": "CONTENT_INVALID_LOCALE",
"message": "That locale is not published.", "payload": { "locale": "fr" } }
]
}
// Reading another service's failure, from the zero-dependency core.
using var response = await client.GetAsync(uri, cancellationToken);
await response.EnsureNoErrorsAsync(cancellationToken); // rethrows the peer's kind and code as your own
An unmapped exception never reaches the caller: it is reported as internal with no message, no
exception type and no stack trace, because that text routinely holds connection strings and SQL. The
exception goes to the log at error level instead, and that log is the only record of it — the
framework's own middleware does not log an exception once a handler has answered it.
The sixteen kinds are google.rpc.Code under names that read better over HTTP, so the same
classification maps to gRPC without a second table. schemas/ publishes the whole contract as JSON
for clients that are not .NET.
Full documentation: https://projectapricot.dev
| 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
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on ApricotFramework.ErrorDefinitions:
| Package | Downloads |
|---|---|
|
ApricotFramework.ErrorDefinitions.AspNetCore
ASP.NET Core integration for ApricotFramework.ErrorDefinitions: an exception handler that turns classified errors into RFC 9457 problem+json responses, an additive registry so a library can map its own exception types without writing a handler, and startup validation of the options. |
|
|
ApricotFramework.Grpc.ErrorDefinitions
The gRPC wire contract for ApricotFramework error definitions: classified errors travel in google.rpc.Status details with their payloads intact, translated in both directions, and a client interceptor rethrows a failed call as the exception the server threw. |
|
|
ApricotFramework.Grpc.Server
Answers a failed gRPC call with classified errors, asking the same exception mappers that already answer this service's HTTP requests, so a failure means the same thing whichever way a caller reached it. |
|
|
ApricotFramework.Grpc.Client
How this service's gRPC clients behave: one place to reach them from, a default deadline for calls that set none, and the transport strictness a deployment asks for. Discovery, credentials and error translation are added on top of it, separately. |
|
|
ApricotFramework.Grpc.Client.Authentication
Presents this service's own access token on outbound gRPC calls, obtained through ApricotFramework.Authentication, and reports a failure to obtain one as a fault of this service rather than of whoever called it. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 294 | 8/15/2026 |