Skip to main content

RepositoryError

Enum RepositoryError 

Source
#[non_exhaustive]
pub enum RepositoryError {
Show 14 variants LockPoisoned(&'static str), Lock(LockError), ConcurrentWrite { id: String, expected: u64, actual: u64, }, DuplicateStreamInBatch { id: String, }, DuplicateOutboxMessageInBatch { id: String, }, DuplicateInboxReceipt { consumer: String, message_id: String, }, InvalidInboxReceipt { consumer: String, message_id: String, }, CausalWriteRequired { table: String, }, InvalidStreamIdentity { aggregate_type: String, aggregate_id: String, reason: String, }, NotFound { id: String, }, InvalidState { id: String, expected: &'static str, actual: String, }, Replay(String), Model(String), Storage { operation: String, retryable: bool, source: Option<Box<dyn Error + Send + Sync>>, },
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

LockPoisoned(&'static str)

§

Lock(LockError)

§

ConcurrentWrite

Fields

§expected: u64
§actual: u64
§

DuplicateStreamInBatch

Fields

§

DuplicateOutboxMessageInBatch

Fields

§

DuplicateInboxReceipt

A consumer inbox receipt (consumer, message_id) was already recorded. The commit is rolled back so the consumer’s effects are not double-applied; the message has already been processed (an at-least-once replay).

Fields

§consumer: String
§message_id: String
§

InvalidInboxReceipt

A consumer inbox receipt had an empty consumer or message_id. Rejected uniformly across backends before any write (the relational CHECK constraints are a defense-in-depth backstop).

Fields

§consumer: String
§message_id: String
§

CausalWriteRequired

A raw/legacy repository batch targeted a causal-owned read-model table.

Fields

§table: String
§

InvalidStreamIdentity

Fields

§aggregate_type: String
§aggregate_id: String
§reason: String
§

NotFound

Fields

§

InvalidState

Fields

§expected: &'static str
§actual: String
§

Replay(String)

§

Model(String)

§

Storage

A storage backend (event store, read model, snapshot store) failed to complete an operation. Unlike RepositoryError::Model — a deterministic modeling/decoding fault — this carries an explicit retry classification so callers can distinguish a transient outage (connection refused, pool timeout, SQLITE_BUSY) from a deterministic failure (constraint violation, malformed row) without string-sniffing the message.

The optional source preserves the underlying error for diagnostics and dead-letter metadata; it is exposed through Error::source.

Fields

§operation: String

The operation that failed (e.g. "sqlite insert event").

§retryable: bool

Whether retrying the same operation may succeed.

§source: Option<Box<dyn Error + Send + Sync>>

The underlying backend error, if available.

Implementations§

Source§

impl RepositoryError

Source

pub fn retryable_storage( operation: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self

Construct a retryable storage failure carrying its source.

Source

pub fn permanent_storage( operation: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self

Construct a permanent storage failure carrying its source.

Source

pub fn kind(&self) -> RetryClass

Classify this error for retry purposes.

The contract a runner relies on: a retryable error should be redelivered (a later attempt may succeed); a permanent error should not, because re-running the identical operation cannot change a deterministic outcome.

  • Storage { retryable, .. } reports the classification captured when the backend error was mapped (connection/pool/timeout → retryable; constraint/decode → permanent).
  • Lock defers to LockError::kind.
  • ConcurrentWrite is retryable: an optimistic-concurrency conflict means another writer won the race; reloading and reapplying typically succeeds. This preserves the prior behavior where it fell into the retryable bucket.
  • NotFound is retryable: under at-least-once delivery it is usually an out-of-order race a later redelivery resolves.
  • The deterministic faults (Model, Replay, invalid identity/receipt, InvalidState, duplicate-in-batch, LockPoisoned) are permanent.
Source

pub fn is_retryable(&self) -> bool

Whether this error is retryable.

Trait Implementations§

Source§

impl Debug for RepositoryError

Source§

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

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

impl Display for RepositoryError

Source§

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

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

impl Error for RepositoryError

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
Source§

impl From<EventRecordError> for RepositoryError

Source§

fn from(err: EventRecordError) -> Self

Converts to this type from the input type.
Source§

impl From<LockError> for RepositoryError

Source§

fn from(err: LockError) -> Self

Converts to this type from the input type.
Source§

impl From<RepositoryError> for HandlerError

Source§

fn from(err: RepositoryError) -> Self

Converts to this type from the input type.
Source§

impl From<RepositoryError> for TransportError

Repository/store failures (lock contention, storage hiccups, stale-claim conflicts) are retryable: usually transient, resolved by a later re-claim. This conversion lives with the outbox bridge — which legitimately knows both the store and the bus — so bus core stays free of RepositoryError.

Source§

fn from(error: RepositoryError) -> Self

Converts to this type from the input type.
Source§

impl From<RepositoryError> for ProjectionProtocolError

Source§

fn from(error: RepositoryError) -> Self

Converts to this type from the input type.
Source§

impl From<TableStoreError> for RepositoryError

Source§

fn from(err: TableStoreError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateBuilder for T

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, 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> Queueable for T

Source§

fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>

Wrap with the default async lock manager. Pair with .aggregate::<T>() for per-aggregate serialization over the async repository surface.
Source§

fn queued_with<L: LockManager>( self, lock_manager: L, ) -> QueuedRepository<Self, L>

Wrap with a custom async lock manager.
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, 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, <T as TryFrom<U>>::Error>

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.