Skip to content

Refactor non-schema errors with thiserror - #7

Draft
yslib wants to merge 9 commits into
mainfrom
feature/thiserror-wrapper-refactor
Draft

Refactor non-schema errors with thiserror#7
yslib wants to merge 9 commits into
mainfrom
feature/thiserror-wrapper-refactor

Conversation

@yslib

@yslib yslib commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • add thiserror 2 and replace handwritten Display, Error, and mechanical From implementations for all 22 non-schema error types
  • preserve immediate typed Error::source() chains and keep only the existing provider-check conversion as a newly derived #[from]
  • add a comprehensive source/no-source characterization suite, including runtime-only failure variants and the complete config-validation source chain
  • retain handwritten Display only where formatting remains genuinely procedural

Why

The error model had accumulated repetitive trait implementations across action, provider, planning, validation, configuration, link, and app-command modules. This refactor makes the type declarations the error contract while preserving the existing domain boundaries and runtime behavior.

Intentional API changes

Three public field representations change to work with thiserror while retaining concrete immediate-source downcasts:

  • LinkError::UnsupportedSourceType.source is renamed to .path because thiserror reserves a field named source for error chaining
  • ConfigValidationError.kind changes from Box<ConfigValidationErrorKind> to direct ConfigValidationErrorKind
  • ConfigLoadError::Validation.source changes from Box<ConfigValidationError> to direct ConfigValidationError

The two direct errors are larger, so the affected validation, configuration, and app modules use documented #[expect(clippy::result_large_err)] attributes. These expectations fail under strict Clippy if they become unnecessary.

Impact

  • command behavior and schema.rs are unchanged
  • production and dependency code removes 569 net lines
  • the test suite adds 553 net lines to characterize every migrated source-bearing and source-less variant
  • no transparent errors or unintended conversion APIs are introduced

Validation

  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets --all-features -- -D warnings
  • cargo test --locked --all-targets --all-features — 314 top-level tests passed
  • isolated Windows GNU cross-target Clippy for x86_64-pc-windows-gnu with all targets and features
  • static audits for all 22 derives, 13 expected #[from] attributes, zero transparent errors, unchanged schema.rs, ignored process docs, and a clean worktree

@yslib yslib changed the title Refactor wrapper errors with thiserror Refactor non-schema errors with thiserror Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant