Skip to main content

sim_lib_operation_gate/
operation_error.rs

1use sim_lib_journal::JournalError;
2use thiserror::Error;
3
4/// Typed refusal from durable operation construction, replay, or publication.
5#[derive(Debug, Error)]
6pub enum OperationError {
7    /// An operation name cannot be empty.
8    #[error("operation name is empty")]
9    EmptyOperation,
10    /// A supplied value was not the canonical value claimed by its identity.
11    #[error("noncanonical {0}")]
12    NonCanonical(&'static str),
13    /// The same claimed operation identity carried different intent.
14    #[error("contradictory intent under one operation id")]
15    ContradictoryIntent,
16    /// A grant did not belong to the stable operation.
17    #[error("operation grant does not match intent")]
18    GrantMismatch,
19    /// An attempt did not belong to the stable operation.
20    #[error("operation attempt does not match intent")]
21    AttemptMismatch,
22    /// A bounded operation lease was empty, expired at acquisition, or moved backwards.
23    #[error("invalid bounded operation lease")]
24    InvalidLease,
25    /// The postcondition observer was the same authority as the performer.
26    #[error("postcondition observer is not independent of the performer")]
27    ObserverNotIndependent,
28    /// Recovery selected a different performer authority for the same operation.
29    #[error("operation performer does not match the durable dispatch authority")]
30    PerformerMismatch,
31    /// Durable replay contained a second intent for one operation.
32    #[error("durable operation contains duplicate intent")]
33    DuplicateIntent,
34    /// A durable event violated the operation state order.
35    #[error("invalid durable operation transition: {0}")]
36    InvalidTransition(&'static str),
37    /// The service has no live fenced writer lease.
38    #[error("operation service must be explicitly resumed")]
39    NotResumed,
40    /// The journal sequence cannot be extended.
41    #[error("operation journal sequence is exhausted")]
42    SequenceExhausted,
43    /// The underlying canonical journal refused the operation.
44    #[error(transparent)]
45    Journal(#[from] JournalError),
46}