crates/kernel/ents-sync/src/error.rs
error.rshistorycomment on this file
| 1 | //! `ents-sync`'s infrastructure error type. |
| 2 | //! |
| 3 | //! An [`Error`] means sync could not *reach* a result — an object could |
| 4 | //! not be read or written, a ref store failed, a commit did not decode. |
| 5 | //! It is never a merge conflict or a negative verdict: a |
| 6 | //! [`crate::Merge::Conflict`] and a [`ents_gate::Verdict::Fail`] are both |
| 7 | //! reached results the caller acts on, not failures to compute one. |
| 8 | |
| 9 | use gix_hash::ObjectId; |
| 10 | |
| 11 | /// Everything that can prevent sync from reaching a result. |
| 12 | #[derive(Debug, thiserror::Error)] |
| 13 | pub enum Error { |
| 14 | /// A ref store (local or remote) failed. The transfer or verdict was |
| 15 | /// neither completed nor refused; retry or surface. |
| 16 | #[error("ref store failed: {0}")] |
| 17 | Refs(#[from] gix_ref_store::Error), |
| 18 | |
| 19 | /// The gate could not evaluate during push pre-flight |
| 20 | /// (`sync.pre-flight`). Distinct from a failing verdict, which is a |
| 21 | /// reached prediction; this is the gate itself failing to compute one. |
| 22 | #[error("gate evaluation failed: {0}")] |
| 23 | Gate(#[from] ents_gate::Error), |
| 24 | |
| 25 | /// An object lookup failed while reading `oid`. |
| 26 | #[error("object lookup failed for {oid}: {source}")] |
| 27 | Object { |
| 28 | /// The object being looked up. |
| 29 | oid: ObjectId, |
| 30 | /// The underlying object-store error. |
| 31 | #[source] |
| 32 | source: gix_object::find::Error, |
| 33 | }, |
| 34 | |
| 35 | /// Writing an object into the destination store failed while |
| 36 | /// transferring the forge (`sync.forge-transfer`). |
| 37 | #[error("object write failed: {0}")] |
| 38 | Write(#[from] gix_object::write::Error), |
| 39 | |
| 40 | /// `oid` is absent from the store it was expected in. During transfer |
| 41 | /// this means the source is missing an object its own ref reaches; |
| 42 | /// during a merge it means a proposed head is not present locally. |
| 43 | #[error("object {oid} is missing")] |
| 44 | Missing { |
| 45 | /// The absent object. |
| 46 | oid: ObjectId, |
| 47 | }, |
| 48 | |
| 49 | /// `oid` exists but could not be decoded as the object kind sync |
| 50 | /// needed (a commit while walking history, or a tree while merging). |
| 51 | #[error("object {oid} could not be decoded: {detail}")] |
| 52 | Decode { |
| 53 | /// The undecodable object. |
| 54 | oid: ObjectId, |
| 55 | /// What failed, human-readable. |
| 56 | detail: String, |
| 57 | }, |
| 58 | |
| 59 | /// A refname could not be constructed while routing to the inbox |
| 60 | /// (`sync.inbox-routing`) — for example, a canonical suffix that is not |
| 61 | /// a valid ref component. |
| 62 | #[error("invalid refname while routing to inbox: {0}")] |
| 63 | RefName(#[from] ents_model::Error), |
| 64 | } |
| 65 | |
| 66 | /// The `Result` alias every fallible `ents-sync` operation returns. |
| 67 | pub type Result<T> = std::result::Result<T, Error>; |