Skip to content

Integrate thiserror and anyhow for structured error handling#5

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/integrate-thiserror-anyhow
Closed

Integrate thiserror and anyhow for structured error handling#5
Copilot wants to merge 4 commits intomainfrom
copilot/integrate-thiserror-anyhow

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 5, 2025

Replaces ad-hoc string-based error handling with typed errors using thiserror for library code and anyhow for CLI context.

Changes

Core Error Types (ktio::error)

Defined 5 error variants covering the entire error surface:

  • IoError: File operations (auto-converts from std::io::Error)
  • ParseError: Sequence format/data parsing
  • InvalidInputError: Invalid nucleotides or sequences
  • ConfigError: Parameter validation
  • SystemError: Memory mapping and resource allocation

Library Updates

  • ktio: seq.rs, mmap.rs return ktio::Result<T>
  • composition: cgr.rs, oligo.rs, oligocgr.rs use typed errors
  • coverage: Updated to use ktio::Result
  • counter, misc: Dependencies added for future migration

CLI Integration

CLI functions now return anyhow::Result with context chains:

// Before
if let Err(e) = com.vectorise() {
    eprintln!("Error: {}", e);
}

// After
com.vectorise()
    .context("Failed to generate oligonucleotide vectors")?;

Error output includes context and cause chains:

Error: Failed to generate oligonucleotide vectors

Caused by:
    0: IO error: No such file or directory (os error 2)
    1: No such file or directory (os error 2)

Documentation

Added ERROR_HANDLING.md with usage patterns and migration guide.


All 45 tests pass. No behavioral changes to existing functionality.

Original prompt

Outline a plan to integrate thiserror and anyhow for more consistent error handling. decide on 5 error types at most.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 5, 2025 01:43
Co-authored-by: anuradhawick <9621844+anuradhawick@users.noreply.github.com>
Co-authored-by: anuradhawick <9621844+anuradhawick@users.noreply.github.com>
Co-authored-by: anuradhawick <9621844+anuradhawick@users.noreply.github.com>
Copilot AI changed the title [WIP] Integrate thiserror and anyhow for consistent error handling Integrate thiserror and anyhow for structured error handling Nov 5, 2025
Copilot AI requested a review from anuradhawick November 5, 2025 02:07
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.19%. Comparing base (78f19f2) to head (b5d853f).

Files with missing lines Patch % Lines
composition/src/cgr.rs 75.00% 2 Missing ⚠️
composition/src/oligocgr.rs 75.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
- Coverage   94.44%   94.19%   -0.25%     
==========================================
  Files          13       13              
  Lines         918      913       -5     
==========================================
- Hits          867      860       -7     
- Misses         51       53       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anuradhawick anuradhawick deleted the copilot/integrate-thiserror-anyhow branch April 11, 2026 08:58
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.

3 participants