Enum FaultyStoreError
#[non_exhaustive]pub enum FaultyStoreError<E> {
Injected,
Contended,
Store(E),
}Expand description
Why a read or an append through a faulty wrapper failed.
The wrapper cannot report the inner store’s error as its own. The reference
store’s is pub enum MemoryStoreError {} — uninhabited — so there is no
value of it to yield for an injected failure. Projecting this type is what
lets the wrapper compile over a store that cannot fail, and what lets a
caller tell the fixture broke this on purpose from my store failed,
which is the one question a test against a fixture has to answer.
§Examples
use happenstance_core::{EventStore, MemoryEventStore};
use happenstance_core::{Query, ReadOptions};
use happenstance_testkit::{FaultyStore, FaultyStoreError};
let store = FaultyStore::new(MemoryEventStore::new()).fail_next_read(1);
let first = happenstance_testkit::block_on(async {
happenstance_core::collect(
store.read(&Query::all(), ReadOptions::new()),
)
.await
});
assert!(matches!(first, Err(FaultyStoreError::Injected)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Injected
The wrapper produced this failure because it was armed to.
Contended
The wrapper refused this append the way a contended store refuses one.
Transient, and that is the entire point. Nothing underneath went
wrong, nothing was written, and the identical call succeeds once the
arming is spent — the shape SQLite produces as SQLITE_BUSY when a
writer waits out busy_timeout without ever acquiring the lock, and
PostgreSQL as a serialisation failure.
It is deliberately not Injected. That variant
means the fixture broke this on purpose; this one means the fixture
was busy, and a caller that cannot tell them apart is the defect this
variant exists to make testable.
§Which channel it arrives on, and why that is the whole instrument
It reaches a caller as
AppendError::Busy(FaultyStoreError::Contended): the contract’s
transient-refusal channel (ES-43), with this variant as the adapter’s
own payload, exactly as a real adapter carries its driver’s error there.
AppendError::is_busy answers true and
AppendError::is_condition_violated answers false.
Until Busy existed it arrived as AppendError::Store, the channel
a caller cannot tell from a real breakage, and that conflation was what
this variant was built to make testable. It moved in the same release
that minted the channel, before either shipped.
Routing it through ConditionViolated instead would be a fixture
telling a lie a real store never tells: no condition was evaluated,
because the lock was never taken.
Store(E)
The wrapped store failed for its own reasons.
The inner error is carried, never rendered: it stays reachable through
source so a caller reports the real
failure rather than this wrapper’s description of it.
Trait Implementations§
§impl<E: Clone> Clone for FaultyStoreError<E>
impl<E: Clone> Clone for FaultyStoreError<E>
impl<E: Copy> Copy for FaultyStoreError<E>
§impl<E: Debug> Debug for FaultyStoreError<E>
impl<E: Debug> Debug for FaultyStoreError<E>
§impl<E: Display> Display for FaultyStoreError<E>
impl<E: Display> Display for FaultyStoreError<E>
impl<E: Eq> Eq for FaultyStoreError<E>
§impl<E: Error + 'static> Error for FaultyStoreError<E>
impl<E: Error + 'static> Error for FaultyStoreError<E>
§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()