use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum SequencerError {
#[error(
"transaction conflicts with admitted txn at batch position {position_admitted}; \
retry with fresh state"
)]
Conflict { position_admitted: u32 },
#[error("sequencer inbox is full; retry after back-off")]
Overloaded,
#[error("sequencer is unavailable; retry after election completes")]
Unavailable,
#[error("not the sequencer leader{}", hint.map(|h| format!("; current leader may be node {h}")).unwrap_or_default())]
NotLeader { hint: Option<u64> },
#[error("vshard {vshard} output sender is gone; scheduler may have exited")]
VshardSenderGone { vshard: u32 },
#[error("transaction plans blob is {bytes} bytes, exceeds limit of {limit} bytes")]
TxnTooLarge { bytes: usize, limit: usize },
#[error("transaction touches {vshards} vshards, exceeds limit of {limit}")]
FanoutTooWide { vshards: usize, limit: usize },
#[error("tenant {tenant} inbox quota exceeded: {in_flight} in flight, quota {quota}")]
TenantQuotaExceeded {
tenant: u64,
quota: usize,
in_flight: usize,
},
#[error("dependent-read payload is {bytes} bytes, exceeds per-txn limit of {limit} bytes")]
DependentReadTooLarge { bytes: usize, limit: usize },
#[error("dependent-read txn touches {passives} passive vshards, exceeds limit of {limit}")]
DependentReadFanoutTooWide { passives: usize, limit: usize },
}