Replace error-chain with thiserror - #16
Open
bmesuere wants to merge 1 commit into
Open
Conversation
Closes #6. error-chain has not seen a release since 2020. All six error_chain! blocks become plain enums deriving thiserror::Error, keeping the same variants, the same messages and the same Error/Result names, so most call sites only lose the ErrorKind indirection. Two bits of error-chain behaviour were load bearing and are kept explicitly: - Error implemented From<String> and From<&str>, which several commands lean on through `.map_err(|e| e.to_string())?` and `.ok_or("...")?`. That is now a Msg variant plus the two From impls. - quick_main! printed the error and then walked the cause chain. main does the same by hand, and read_taxa_file keeps its io error as a real source rather than formatting it into the message, so the output is unchanged: Error: Failed opening taxon file. Caused by: No such file or directory (os error 2) Verified against the old binary: identical stderr and exit code for a missing taxon file, a malformed taxon file and an unknown taxon ID. 38 tests pass and the pipeline still runs end to end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 18, 2026
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.
Closes #6.
error-chainhas had no release since 2020.All six
error_chain!blocks become plain enums derivingthiserror::Error, keeping the same variants, the same messages and the sameError/Resultnames — so most call sites just lose theErrorKindindirection.Two bits of error-chain behaviour that were load bearing
From<String>andFrom<&str>. error-chain generated these, and several commands lean on them via.map_err(|e| e.to_string())?and.ok_or("...")?. Dropping them silently would have been a compile error in some places and a behaviour change in others, so they are now aMsgvariant plus two explicitFromimpls.quick_main!printed the cause chain.mainnow does that by hand, andread_taxa_filekeeps its io error as a real#[source]rather than formatting it into the message. Output is byte-identical to before:My first attempt flattened that into one line; keeping the source chain is both closer to the old behaviour and the point of using thiserror.
Verification
Compared against the old binary: identical stderr and exit code for a missing taxon file, a malformed taxon file, and an unknown taxon ID. 38 tests pass,
cargo +nightly fmt --checkclean, and the pipeline runs end to end through FragGeneScanRs to tryptic peptides.Two pre-existing things I noticed, not touched here
umgap translate -t 99panics withindex out of bounds: the len is 23 but the index is 98atsrc/dna/translation.rs:181. The bounds check that would produceUnknownTablesits after the indexing. Both the old and new binaries panic identically, so this is not a regression — but it is a real bug and probably wants its own issue.Fromimpls and enums attract a few more lints. The clippy cleanup is still its own piece of work.