Skip to main content

Module error

Module error 

Source
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 by Workspace::load.
  • ApplyError — surfaced by Workspace::apply.
  • SaveError — surfaced by Workspace::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§

ApplyError
Failure during Workspace::apply.
ApplyErrorKind
ApplyError’s failure class.
ConfigError
#[non_exhaustive] (RFC 041)
ConfigErrorKind
ConfigError’s failure class, one variant per ConfigError variant. See the module doc for why this exists and how it differs from apimock::cmd::envelope::ErrorKind.
SaveError
Failure during Workspace::save.
SaveErrorKind
SaveError’s failure class.
WorkspaceError
Failure during Workspace::load. Currently a thin wrapper around ConfigError — kept as its own type so the Workspace API signals intent at the type level and has room to grow (e.g. “path is not a directory”, “no root config found”).
WorkspaceErrorKind
WorkspaceError’s failure class. Does not delegate to ConfigErrorKind (RFC 041’s handoff § 4, decided explicitly): WorkspaceError exists so the Workspace API signals intent at the type level, and delegating its kind() would leak ConfigError’s taxonomy through the type whose whole purpose is to have its own.

Type Aliases§

ConfigResult