Refactor non-schema errors with thiserror - #7
Draft
yslib wants to merge 9 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
thiserror2 and replace handwrittenDisplay,Error, and mechanicalFromimplementations for all 22 non-schema error typesError::source()chains and keep only the existing provider-check conversion as a newly derived#[from]Displayonly where formatting remains genuinely proceduralWhy
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
thiserrorwhile retaining concrete immediate-source downcasts:LinkError::UnsupportedSourceType.sourceis renamed to.pathbecausethiserrorreserves a field namedsourcefor error chainingConfigValidationError.kindchanges fromBox<ConfigValidationErrorKind>to directConfigValidationErrorKindConfigLoadError::Validation.sourcechanges fromBox<ConfigValidationError>to directConfigValidationErrorThe 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
schema.rsare unchangedtransparenterrors or unintended conversion APIs are introducedValidation
cargo fmt --all -- --checkcargo clippy --locked --all-targets --all-features -- -D warningscargo test --locked --all-targets --all-features— 314 top-level tests passedx86_64-pc-windows-gnuwith all targets and features#[from]attributes, zerotransparenterrors, unchangedschema.rs, ignored process docs, and a clean worktree