crates/kernel/ents-receive/src/error.rs
error.rshistorycomment on this file
| 1 | //! `ents-receive`'s infrastructure error type. |
| 2 | //! |
| 3 | //! An [`Error`] means `receive` could not *reach* an outcome (a store read |
| 4 | //! failed, an object is missing or undecodable, an [`crate::EventSink`] |
| 5 | //! failed to durably enqueue) — as opposed to an ordinary refusal |
| 6 | //! ([`ents_gate::Verdict::Fail`], [`crate::TxResult::Refused`], |
| 7 | //! [`crate::TxResult::Rejected`], [`crate::TxResult::Redacted`]), which is a |
| 8 | //! reached judgment carried inside [`crate::Outcome`], not an `Err`. |
| 9 | |
| 10 | use gix_hash::ObjectId; |
| 11 | |
| 12 | /// Everything that can prevent `receive` from reaching an outcome. |
| 13 | #[derive(Debug, thiserror::Error)] |
| 14 | pub enum Error { |
| 15 | /// The gate could not evaluate a proposed transition. |
| 16 | #[error("gate evaluation failed: {0}")] |
| 17 | Gate(#[from] ents_gate::Error), |
| 18 | |
| 19 | /// The ref store's read or write half failed. |
| 20 | #[error("ref store operation failed: {0}")] |
| 21 | Refs(#[from] gix_ref_store::Error), |
| 22 | |
| 23 | /// The query evaluator could not compute an entry or work set. |
| 24 | #[error("query evaluation failed: {0}")] |
| 25 | Eval(#[from] ents_query::EvalError), |
| 26 | |
| 27 | /// An `EventSink` failed to durably enqueue an obligation. |
| 28 | /// |
| 29 | /// `receive.never-blocks` still holds: this only ever wraps a genuine |
| 30 | /// sink failure (durable-queue I/O, hosted), never effect evaluation |
| 31 | /// itself, which this crate never performs. |
| 32 | #[error("event sink failed to enqueue ({effect}, {oid}): {detail}")] |
| 33 | Sink { |
| 34 | /// The effect the obligation was for. |
| 35 | effect: String, |
| 36 | /// The commit the obligation names. |
| 37 | oid: ObjectId, |
| 38 | /// What failed, human-readable. |
| 39 | detail: String, |
| 40 | }, |
| 41 | |
| 42 | /// An object could not be read or decoded while scanning |
| 43 | /// `refs/meta/effects/*` or `refs/meta/redactions/*`. |
| 44 | #[error("object {oid} could not be read: {detail}")] |
| 45 | Decode { |
| 46 | /// The undecodable object. |
| 47 | oid: ObjectId, |
| 48 | /// What failed, human-readable. |
| 49 | detail: String, |
| 50 | }, |
| 51 | |
| 52 | /// A typed entity could not be serialized into a tree |
| 53 | /// ([`crate::propose_entity`]'s first step). |
| 54 | #[error("typed-tree operation failed: {0}")] |
| 55 | Tree(#[from] facet_git_tree::Error), |
| 56 | |
| 57 | /// A built commit object could not be written to the object store |
| 58 | /// ([`crate::propose_entity`]'s signed commit, or its bound-parent |
| 59 | /// deletion transition). |
| 60 | #[error("object write failed: {0}")] |
| 61 | ObjectWrite(#[from] gix_object::write::Error), |
| 62 | |
| 63 | /// A refname could not be built from a genesis commit's oid |
| 64 | /// ([`crate::propose_genesis`]'s name-from-oid step). This cannot |
| 65 | /// occur for a real oid, whose hex is always a valid refname segment. |
| 66 | #[error("naming a ref from signed content failed: {source}")] |
| 67 | Model { |
| 68 | /// The underlying model error. |
| 69 | source: ents_model::Error, |
| 70 | }, |
| 71 | } |
| 72 | |
| 73 | /// The `Result` alias every fallible `ents-receive` operation returns. |
| 74 | pub type Result<T> = std::result::Result<T, Error>; |