Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/edda

crates/gunnar-delta/src/error.rs

//! Errors: one enum, `thiserror`, gix's convention.

/// Anything that can go wrong producing a delta.
///
/// Note what is *not* here: "the delta came out too big" is not an error, it is
/// an ordinary outcome, and it is reported as `Ok(None)` by
/// [`crate::delta_into`]. Reserving the error channel for refusals and genuine
/// failures is what lets the window search treat an over-budget candidate as a
/// skip without pattern-matching on error variants.
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
    /// The request was rejected **before** anything was allocated for it.
    ///
    /// A sliding window over a large object set is a shape that turns a
    /// plausible-looking parameter into an out-of-memory kill, so every such
    /// parameter is bounded by [`crate::Limits`] and an out-of-bounds request is
    /// refused rather than attempted. See `Limits` for the reasoning per field.
    #[error("refused: {what} is {requested}, above the configured limit of {limit}")]
    Refused {
        what: &'static str,
        requested: u64,
        limit: u64,
    },

    /// `should_interrupt` was set while the search was running.
    #[error("interrupted")]
    Interrupted,

    /// The encoder produced instructions that do not reconstruct the target.
    ///
    /// This is an internal-consistency check, not a user error: the emitter
    /// counts the bytes its own instructions will produce and compares that to
    /// the target length before returning. It exists because a wrong delta does
    /// not fail here. It fails at some later clone, as a corrupt repository,
    /// arbitrarily far from the cause.
    #[error("internal: delta instructions produce {produced} bytes, target is {expected}")]
    Inconsistent { produced: u64, expected: u64 },
}

/// The crate's result alias.
pub type Result<T> = std::result::Result<T, Error>;