From 6979a20414e2f6deaa37176298f6703d3ee9278c Mon Sep 17 00:00:00 2001 From: Stephen Waits <1+swaits@noreply.git.swaits.com> Date: Sun, 11 Oct 2026 01:37:12 +0000 Subject: [PATCH] First slice: ledger-store (journal+blobs+sqlite) and ledger-mcp (18 tools, receipt policy) --- crates/ledger-store/src/error.rs | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 crates/ledger-store/src/error.rs diff --git a/crates/ledger-store/src/error.rs b/crates/ledger-store/src/error.rs new file mode 100644 index 0000000..5664ef2 --- /dev/null +++ b/crates/ledger-store/src/error.rs @@ -0,0 +1,59 @@ +//! Error type for the store. + +use thiserror::Error; + +/// Every way a store operation can fail. +#[derive(Debug, Error)] +pub enum StoreError { + /// Filesystem error. + #[error("io error: {0}")] + Io(#[from] std::io::Error), + + /// SQLite error. + #[error("sqlite error: {0}")] + Rusqlite(#[from] rusqlite::Error), + + /// JSON error. + #[error("json error: {0}")] + Json(#[from] serde_json::Error), + + /// The engine rejected the operation. The journal is untouched. + #[error("ledger error: {0}")] + Ledger(#[from] ledger_core::LedgerError), + + /// The journal failed integrity verification. + #[error("journal corrupt: {0}")] + JournalCorrupt(String), + + /// Replay produced different ids than the journal recorded. + #[error("replay mismatch: {0}")] + ReplayMismatch(String), + + /// [`crate::Store::verify`] found divergence. + #[error("verify failed: {0}")] + VerifyMismatch(String), + + /// A blob's bytes did not match its SHA-256. + #[error("blob corrupt: hash mismatch for {0}")] + CorruptBlob(String), + + /// Referenced attachment does not exist. + #[error("unknown attachment {0}")] + UnknownAttachment(u64), + + /// The store's schema is newer than this binary understands. + #[error("schema version {0} newer than supported {1}")] + SchemaTooNew(u32, u32), + + /// `create` called where a store already exists. + #[error("store already exists at {0}")] + AlreadyExists(String), + + /// `open` called where no store exists. + #[error("store not found at {0}")] + NotFound(String), + + /// The requested base currency differs from the store's. + #[error("base currency mismatch: store is {0}, requested {1}")] + CurrencyMismatch(String, String), +}