Rkd.Scalar.Errors
2.13.0
dotnet add package Rkd.Scalar.Errors --version 2.13.0
NuGet\Install-Package Rkd.Scalar.Errors -Version 2.13.0
<PackageReference Include="Rkd.Scalar.Errors" Version="2.13.0" />
<PackageVersion Include="Rkd.Scalar.Errors" Version="2.13.0" />
<PackageReference Include="Rkd.Scalar.Errors" />
paket add Rkd.Scalar.Errors --version 2.13.0
#r "nuget: Rkd.Scalar.Errors, 2.13.0"
#:package Rkd.Scalar.Errors@2.13.0
#addin nuget:?package=Rkd.Scalar.Errors&version=2.13.0
#tool nuget:?package=Rkd.Scalar.Errors&version=2.13.0
Rkd.Scalar.Errors
The errors of Rkd.Scalar for any layer — Domain, Application,
Infrastructure. Throw them anywhere; WithProblemDetails() in the API project turns them into RFC 9457 problem details
with a stable code.
dotnet add src/MyApp.Application package Rkd.Scalar.Errors
dotnet add src/MyApp.Api package Rkd.Scalar
// MyApp.Application — references Rkd.Scalar.Errors only
using Rkd.Scalar; // RkdError, ProblemException, IProblemLogDetails
public static class CustomerErrors
{
public const string AlreadyExists = "CUSTOMER_ALREADY_EXISTS";
}
if (await customers.ExistsAsync(command.Document, cancellationToken))
throw RkdError.Conflict(CustomerErrors.AlreadyExists, "A customer with this document already exists.")
.WithLogDetails($"document={command.Document}"); // logged, never sent to the client
// MyApp.Api — references Rkd.Scalar
builder.AddRkdScalar().WithProblemDetails();
{
"title": "Conflict",
"status": 409,
"detail": "A customer with this document already exists.",
"code": "CUSTOMER_ALREADY_EXISTS",
"traceId": "00-…"
}
| Type | Use |
|---|---|
RkdError |
Conflict, NotFound, UnprocessableEntity, Validation… with a stable error code |
ProblemException |
The exception they create; derive from it for your own problems |
IProblemLogDetails |
Technical details of your own exceptions, written to the log only |
Namespace
Every type is in Rkd.Scalar, whichever package brings it (this one or Rkd.Scalar):
using Rkd.Scalar;
- Not
Rkd.Scalar.Errors: that is the name of the package, not a namespace. - Not
Rkd.Problems: that is the dependency with the client side of the contract (HttpProblemException,EnsureSuccessOrThrowProblemAsync,ProblemCodes,ProblemMembers), what a failed call to another API throws. It has noProblemException.
The same using in tests:
using Rkd.Scalar;
var problem = await Assert.ThrowsAsync<ProblemException>(() => service.CreateAsync(command, ct));
Assert.Equal(CustomerErrors.AlreadyExists, problem.Code);
Notes
- Same types and namespace (
Rkd.Scalar) used by Rkd.Scalar, which depends on this package. - Dependencies: Rkd.Problems (the member names and codes shared with
the clients) and the ASP.NET Core shared framework, needed by
ProblemException.ToProblemDetails(). No other package: no Scalar, OpenAPI, API versioning or authentication. - Validators, signers, key resolvers and HTTP log sinks implemented outside the API project are in Rkd.Scalar.Abstractions.
See the Rkd.Scalar documentation.
| 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
- Rkd.Problems (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rkd.Scalar.Errors:
| Package | Downloads |
|---|---|
|
Rkd.Scalar
Zero-boilerplate Scalar wrapper for ASP.NET Core. Configures OpenAPI, API Versioning and Authentication (JWT with HMAC, RSA, ECDSA, OIDC/JWKS or async/KMS signing, Basic, API Key) in a few fluent lines, applies XML documentation comments automatically, standardizes errors as RFC 9457 problem details, with built-in documentation UI protection, a development login endpoint and configuration-based validators. |
GitHub repositories
This package is not used by any popular GitHub repositories.