ModKit Canonical Errors
Canonical error types for CyberFabric modules, based on the Google AIP-193 error model.
Overview
The cf-modkit-canonical-errors crate provides:
CanonicalError– a structured error type with category, message, and rich contextresource_error!– a macro for declaring resource-scoped error types with generated constructors- Typed error-context structs for every canonical category (
InvalidArgument,NotFound,PermissionDenied,Internal, etc.) Problem– RFC-9457 problem detail representation for HTTP responses
Usage
Resource-scoped errors (via macro)
use CanonicalError;
resource_error!;
// Not-found with a resource identifier
let err = not_found
.with_resource
.create;
// Invalid-argument with field violations
let err = invalid_argument
.with_field_violation
.create;
System-level errors (direct constructors)
use CanonicalError;
let err = unauthenticated
.with_reason
.create;
let err = internal
.create;
License
Licensed under Apache-2.0.