Skip to main content

resource_error

Macro resource_error 

Source
macro_rules! resource_error {
    ($vis:vis $name:ident, $gts_type:literal) => { ... };
}
Expand description

Generates a resource error type with builder-returning constructors for the 13 canonical error categories that carry a resource_type.

Generated constructors either accept a detail string or are zero-argument (using a default message). Each returns a ResourceErrorBuilder with typestate enforcement โ€” required fields must be set via builder methods (e.g. .with_resource(...), .with_reason(...)) before .create() compiles.

Categories where resource_type is absent (internal, service_unavailable, unauthenticated) are not generated โ€” use CanonicalError::*() directly for those.

The GTS type literal is validated at compile time.

ยงExample

โ“˜
resource_error!(TenantResourceError, "gts.cf.core.tenants.tenant.v1~");

let err = TenantResourceError::not_found("tenant not found")
    .with_resource("tenant-123")
    .create();
assert_eq!(err.resource_type(), Some("gts.cf.core.tenants.tenant.v1~"));