Skip to main content

CacheError

Enum CacheError 

Source
pub enum CacheError {
    NotFound {
        hash: Hash,
    },
    HashMismatch {
        expected: Hash,
        actual: Hash,
    },
    VerifyFailed {
        expected: Hash,
    },
    BlobTooLarge {
        hash: Hash,
        limit_bytes: u64,
    },
    NoOrigin {
        hash: Hash,
    },
    OriginError {
        hash: Hash,
        source: Error,
    },
    Store(Error),
    Feed(Error),
    Internal(Error),
    EvictionLimitExceeded {
        limit: usize,
    },
}
Expand description

Errors surfaced by crate::CacheEngine.

A variant that wraps a cause names only itself in Display and returns the cause from std::error::Error::source. A .chain() walk therefore reaches every cause under a CacheError, such as a local disk fault that decdn_client::classify looks for, and a chain formatter ({:#} or {:?} on an anyhow::Error) names each cause once. Log a bare CacheError with CacheError::display_chain, not with plain Display.

Variants§

§

NotFound

The requested blob was not found locally and the configured origin returned a not-found response.

Fields

§hash: Hash

The hash that was requested.

§

HashMismatch

The origin returned bytes whose BLAKE3 hash did not match what was requested. The bytes are rejected and are not inserted into the store. A whole-stream failure: the assembled bytes hashed to actual, not the requested expected. A mid-stream bao chunk-group verify failure surfaces as Self::VerifyFailed instead, so actual here is always a real hash.

Fields

§expected: Hash

The hash the caller asked for.

§actual: Hash

The hash the origin’s bytes actually produced.

§

VerifyFailed

A teed bao verified-stream (#856, ADR 038) failed to decode against the content root: an interior chunk group did not verify — a corrupt or lying upstream. Distinct from Self::HashMismatch, which is a whole-stream hash mismatch; here the failure is at an interior group, so there is no meaningful whole-blob “actual” hash to report (#915). The bytes are rejected and are not inserted into the store.

Fields

§expected: Hash

The hash the caller asked for (the content root the stream failed to verify against).

§

BlobTooLarge

The origin returned a blob larger than the configured max_blob_size_mb.

Fields

§hash: Hash

The hash that was requested.

§limit_bytes: u64

The configured ceiling, in bytes.

§

NoOrigin

The cache engine was asked to pull a miss but no origin was configured.

Fields

§hash: Hash

The hash that was requested.

§

OriginError

The origin backend failed (network error, non-200 status, etc).

Fields

§hash: Hash

The hash that was requested.

§source: Error

Underlying error from the origin backend.

§

Store(Error)

This node’s own iroh-blobs store failed, or a store operation asked for bytes the store does not hold. Always a local fault: the bytes a sender feeds into an admit failing to arrive is Self::Feed, and bytes that fail to verify are Self::VerifyFailed.

§

Feed(Error)

The bao stream fed into an admit ended early or failed to read, or its claimed size cannot belong to the hash. A fault of the sender’s delivery, not of this node’s store.

§

Internal(Error)

A code bug in the cache: a broken internal invariant or a caught panic. Never an origin fault and never a store fault, so an operator reads it as a bug to report, not as a backend to check.

§

EvictionLimitExceeded

The local evicted-hash set is full. Hard cap on the number of distinct hashes the operator may evict in a single cache lifetime (issue #279) — protects the in-memory HashSet and the on-disk evicted.log from unbounded growth under e.g. an automation gone-wrong that mass-evicts on every request. Hitting this is well outside normal usage; the operator should investigate the caller before raising the cap.

Fields

§limit: usize

The cap that was reached.

Implementations§

Source§

impl CacheError

Source

pub fn display_chain(&self) -> ErrorChain<'_>

Render this error and every cause under it on one line (store error: context: root cause). Use it wherever a bare CacheError reaches a log line or an operator-facing message.

Source

pub fn origin_error_kind(&self) -> Option<&OriginError>

Walk the source chain of Self::OriginError looking for an OriginError. Returns Some when the failure originated in the HTTP origin’s encoding/decompression layer, even after anyhow::Context::with_context wrappers were stacked on top — anyhow::Error::chain() exposes every cause in the chain, and the typed variant we want lives at the root.

Tests assert on the typed variant via matches!; observability code can switch on the variant rather than parsing Display strings. Returns None for non-origin failures or origin failures that didn’t come from HttpOrigin’s decoder.

Trait Implementations§

Source§

impl Debug for CacheError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CacheError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CacheError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more