Repository navigation
feat: migrate engine layer to thiserror with CoraError enum (#86) - #143
Merged
Merged
Conversation
Replace anyhow with typed CoraError enum (17 variants) in engine layer: - LLM: request, status, parse, stream, json repair, timeout - Config: parse, read, no API key - Git: invalid ref, command failure, not in repo, head detached - Cache: I/O, serialize - Scanner, auth, hook errors CLI/command layer retains anyhow for ergonomics. Engine layer returns Result<T, CoraError> for programmatic matching. Prerequisite for #116 (rule engine needs typed error output). 224 tests pass, clippy clean, fmt clean. Closes #86 Co-Authored-By: codecoradev <noreply@github.com>
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (2)
Review powered by cora-cli · BYOK · MIT |
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
Migrate engine layer from anyhow to typed
CoraErrorenum viathiserror = "2".New file:
src/error.rs—CoraErrorenum with 17 variantsModified (10 files):
Cargo.toml— addedthiserror = "2"src/main.rs— addedmod errorengine/llm.rs,engine/review.rs,engine/scanner.rs,engine/cache.rs→Result<T, CoraError>config/loader.rs,config/schema.rs→ typed errorsgit/diff.rs→ typed errorscommands/review.rs→map_err(Into::into)for CoraError→anyhow conversionCoraError variants: LlmRequest, LlmStatus, LlmParse, LlmStream, LlmJsonRepair, ConfigParse, ConfigRead, NoApiKey, DiffTooLarge, InvalidRef, GitCommand, NotInGitRepo, HeadDetached, CacheIo, CacheSerialize, ScannerError, AuthError, HookError, Timeout
Design decisions:
Result<T, CoraError>(typed, programmatic matching)anyhow::Result(ergonomic, auto-converts via?)#[from]forreqwest::Errorandstd::io::Error(standard thiserror pattern)Verification: 224 tests ✅ | clippy clean ✅ | fmt clean ✅ | local binary test ✅
Prerequisite for: #116 (pre-LLM rule engine needs typed error output)
Closes #86
Co-Authored-By: codecoradev noreply@github.com