-
Notifications
You must be signed in to change notification settings - Fork 0
fix(serve,ledger): add .context() to error propagation in critical paths #377
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Error context enrichment is nearly zero across the codebase:
| Crate | Bare `?` | `.context()` | Ratio |
|---|---|---|---|
| edda-ledger | 613 | 1 | 0.16% |
| edda-cli | 546 | 6 | 1.1% |
| edda-serve | 215 | 9 | 4.2% |
When a production error occurs, the error message only contains the lowest-level detail (e.g., "no such column") with no information about which endpoint, decision key, project, or operation triggered it. Debugging is extremely difficult.
Scope
Prioritize adding .context() in:
- edda-serve handlers — each
?should include the endpoint name and key request params - edda-ledger public API — each
Ledger::*method should wrap errors with the method name and key args - edda-cli commands — each
cmd_*.rsexecute function should context-wrap ledger calls
Examples
// Before
let ledger = Ledger::open(&root)?;
// After
let ledger = Ledger::open(&root)
.context(format!("opening ledger at {}", root.display()))?;// Before (edda-serve handler)
let decisions = ledger.active_decisions()?;
// After
let decisions = ledger.active_decisions()
.context("GET /api/decisions: fetching active decisions")?;Notes
anyhowis already a workspace dependency —.context()is available everywhere- Start with the most-changed files (serve lib.rs, sqlite_store.rs, ledger.rs)
- This is incremental — doesn't need to be done all at once
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request