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.
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
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
BlobTooLarge
The origin returned a blob larger than the configured
max_blob_size_mb.
NoOrigin
The cache engine was asked to pull a miss but no origin was configured.
OriginError
The origin backend failed (network error, non-200 status, etc).
Fields
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.
Implementations§
Source§impl CacheError
impl CacheError
Sourcepub fn display_chain(&self) -> ErrorChain<'_>
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.
Sourcepub fn origin_error_kind(&self) -> Option<&OriginError>
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
impl Debug for CacheError
Source§impl Display for CacheError
impl Display for CacheError
Source§impl Error for CacheError
impl Error for CacheError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for CacheError
impl RefUnwindSafe for CacheError
impl Send for CacheError
impl Sync for CacheError
impl Unpin for CacheError
impl UnsafeUnpin for CacheError
impl UnwindSafe for CacheError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.