Skip to content

Flatten internal client::Error enum (deferred from v0.3.0 bundle) #75

@StefanSteiner

Description

@StefanSteiner

Context

Deferred from the v0.3.0 bundle (Follow-up D in the four #70 follow-ups). The public hyperdb_api::Error was flattened in #70 per the Microsoft Pragmatic Rust Guidelines (M-ERRORS-CANONICAL-STRUCTS, M-ERRORS-AVOID-WRAPPING-AND-AS-DYN). The internal hyperdb_api_core::client::Error type still uses the older struct-with-kind shape.

Why deferred

client::Error is internal — not re-exported from hyperdb-api, no public callers. The benefit of flattening it is purely codebase-internal hygiene; v0.3.0 ships with all user-facing error improvements without it.

Scope is non-trivial:

  • ~51 producer call sites in hyperdb-api-core/src/client/{client,async_client,connection,grpc/*,tls}.rs
  • 15 ErrorKind variants: Connection, Authentication, Query, Protocol, Io, Config, Timeout, Cancelled, Closed, Conversion, FeatureNotSupported, InvalidData, InvalidInput, UnexpectedEof, Other
  • Touches the From<client::Error> for hyperdb_api::Error mapping (currently exhaustive over ErrorKind — must be updated to match against the new flat shape)

Plan: ship as a chore: PR in v0.3.x. No public API change; mechanical migration mirroring #70's pattern.

Approach

Same shape as #70 applied to the internal type:

  1. Define a flat client::Error enum, one variant per current ErrorKind variant. Use thiserror. No Box<dyn StdError> cause channel.
  2. Add ergonomic snake_case constructors taking impl Into<String> for every variant.
  3. Sweep the ~51 producer sites file-by-file using a per-call-site mapping table.
  4. Update the From<client::Error> for hyperdb_api::Error impl in hyperdb-api/src/error.rs to match against the new flat shape.
  5. Verify cargo build/clippy/test/doc clean across the workspace.

Acceptance criteria

  • client::Error is a flat #[non_exhaustive] enum with no Box<dyn> cause channel
  • Every variant has an impl Into<String> constructor
  • All ~51 producer sites use the new constructors
  • From<client::Error> for hyperdb_api::Error mapping is updated and exhaustive
  • cargo build --workspace --all-targets clean
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo test --workspace (full, including doctests) green
  • cargo doc --workspace --no-deps warning count ≤ baseline
  • No public API impact (verify by grepping for external consumers of client::Error / client::ErrorKind — currently zero)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions