use crate::types::{Role, Verb};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum EngineError {
#[error("lock busy ({0})")]
LockBusy(&'static str),
#[error("lock busy after retry ({0})")]
LockBusyAfterRetry(&'static str),
#[error("token signature invalid")]
BadSignature,
#[error("token expired")]
TokenExpired,
#[error("token uses exhausted")]
TokenUsesExhausted,
#[error("token not found in store (nonce={0})")]
TokenNotFound(String),
#[error("role violation: role={role:?} verb={verb:?}")]
RoleViolation {
role: Role,
verb: Verb,
},
#[error("task not found: {0}")]
TaskNotFound(String),
#[error("session not found")]
SessionNotFound,
#[error("resume key not found")]
ResumeKeyNotFound,
#[error("resource not found: {0}")]
ResourceNotFound(String),
#[error("invalid state transition: {0}")]
InvalidTransition(String),
#[error("dispatch failed: {0}")]
DispatchFailed(String),
#[error("poll timeout")]
PollTimeout,
#[error("cancelled")]
Cancelled,
#[error("spawn depth exceeded: {current} >= max {max}")]
SpawnDepthExceeded {
current: u32,
max: u32,
},
#[error("token task mismatch: token bound to {bound}, arg was {arg}")]
TokenTaskMismatch {
bound: String,
arg: String,
},
#[error("internal: {0}")]
Internal(String),
}