Expand description
Typed engine-error surface (issue #58.6).
RFC-012 Stage 1a: moved from ff-sdk::engine_error to
ff-core::engine_error so it becomes nameable by the
EngineBackend trait (which lives in ff-core::engine_backend) without
forcing a public-surface dependency from ff-core on ff-script. The
[ScriptError]-aware helpers (From<ScriptError>, valkey_kind,
transport_script, transport_script_ref) live in ff-script as
free functions (see ff_script::engine_error_ext) — ff-core owns
the enum shapes; ff-script owns the transport-downcast plumbing.
§Mapping shape
ScriptError lives in the ff-script crate (transport-adjacent).
EngineError lives here in ff-core and is what public SDK calls
return via ff_sdk::SdkError::Engine. The bidirectional mapping:
From<ScriptError> for EngineError— everyScriptErrorvariant is classified intoNotFound/Validation/Contention/Conflict/State/Bug/Transport.Parse+Valkeyflow throughTransport { source: Box<ScriptError> }so the underlyingferriskey::ErrorKind/ parse detail is preserved.DependencyAlreadyExistsis special: per the #58.6 design the variant carries the pre-existing [EdgeSnapshot] inline. Populating that field requires an extra round-trip (the Lua script only knows the edge_id), so plainFrom<ScriptError>returns aTransportfallback for that code — callers in thestage_dependencypath useff_sdk::engine_error::enrich_dependency_conflictto perform the follow-updescribe_edgeand upgrade the error before returning.
§Exhaustiveness
The top-level EngineError and every sub-kind are
#[non_exhaustive]. FF can add new Lua error codes in minors
without a breaking change to this surface — consumers that
match on a sub-kind must include a _ arm.
Enums§
- Backend
Error - Backend-agnostic transport error carried across public ff-sdk / ff-server error surfaces (#88).
- Backend
Error Kind - Classified backend transport errors, kept backend-agnostic on purpose (#88). Each variant maps a family of native backend error kinds into a stable, consumer-matchable shape.
- BugKind
- FF-internal invariant-violation sub-kinds. Should not be reachable in a correctly-behaving deployment.
- Conflict
Kind - Permanent conflict sub-kinds. Caller must reconcile rather than retry.
- Contention
Kind - Contention sub-kinds (retryable per RFC-010 §10.7). Caller should re-dispatch or re-read and retry.
- Engine
Error - Typed engine-error surface. See module docs.
- State
Kind - Legal-but-surprising state sub-kinds. Per-variant semantics vary (some are benign no-ops, some are terminal). Consult the RFC-010 §10.7 classification table.
- Validation
Kind - Validation sub-kinds. 1:1 with the Lua validation codes.
Functions§
- backend_
context - Wrap an
EngineErrorwith a call-site label when the error is a transport-family fault —TransportorUnavailable. Typed classifications (NotFound,Validation,Contention,Conflict,State,Bug) form the public contract boundary for consumers thatmatchon the variant, so we return them unchanged. Repeated wraps on an already-Contextualerror nest an additional layer; callers should wrap once per op boundary.