Expand description
Errors surfaced by the config crate.
See apimock_routing::error for the rationale on per-crate error
types. ConfigError wraps RoutingError via #[from] so rule-set
load failures flow through without the caller pattern-matching on
origin.
§5.1.0 additions
WorkspaceError— surfaced byWorkspace::load.ApplyError— surfaced byWorkspace::apply.SaveError— surfaced byWorkspace::save.
Each of the three “operation” errors wraps ConfigError via
#[from] because the underlying cause of most workspace failures
is a plain config load / write problem.
§#[non_exhaustive] and kind() (RFC 041)
All four enums here are #[non_exhaustive] — a public error type is
exactly where a new variant is most likely to be added later, so
leaving it exhaustively matchable freezes today’s variant set as a
public contract by accident. Each gains a kind() accessor
returning its own #[non_exhaustive] *Kind enum, mechanically one
kind per variant, so a caller forced into a wildcard match arm by
#[non_exhaustive] still has a stable way to branch on failure
class instead of falling back to matching on Display text.
This is a different taxonomy from apimock::cmd::envelope::ErrorKind,
deliberately. That one is the CLI’s published contract, with a
schema version and a stability promise to agents. These kind()
methods describe library failures for library callers. Neither
delegates to the other — fusing them would tie a published CLI
contract to internal error refactoring.
A variant that wraps another crate’s error (ConfigError::RuleSet,
WorkspaceError::Config, …) gets its own kind naming that it
wrapped something, not the inner error’s kind — kind() describes
this enum’s variant, one-to-one, never a second hop into a nested
type’s own taxonomy. A caller wanting the inner detail already has
Error::source() for that.
Enums§
- Apply
Error - Failure during
Workspace::apply. - Apply
Error Kind ApplyError’s failure class.- Config
Error #[non_exhaustive](RFC 041)- Config
Error Kind ConfigError’s failure class, one variant perConfigErrorvariant. See the module doc for why this exists and how it differs fromapimock::cmd::envelope::ErrorKind.- Save
Error - Failure during
Workspace::save. - Save
Error Kind SaveError’s failure class.- Workspace
Error - Failure during
Workspace::load. Currently a thin wrapper aroundConfigError— kept as its own type so theWorkspaceAPI signals intent at the type level and has room to grow (e.g. “path is not a directory”, “no root config found”). - Workspace
Error Kind WorkspaceError’s failure class. Does not delegate toConfigErrorKind(RFC 041’s handoff § 4, decided explicitly):WorkspaceErrorexists so theWorkspaceAPI signals intent at the type level, and delegating itskind()would leakConfigError’s taxonomy through the type whose whole purpose is to have its own.