//! Workflow error types.

#[derive(Debug, thiserror::Error)]
pub enum WorkflowError {
    #[error("stage '{0}' failed: {1}")]
    StageFailed(String, String),

    #[error("edge condition unsatisfied: {0} -> {1}")]
    EdgeConditionFailed(String, String),

    #[error("compensation failed at stage '{0}': {1}")]
    CompensationFailed(String, String),

    #[error("workflow verification failed: {0}")]
    VerificationFailed(String),

    #[error("stage not found: '{0}'")]
    StageNotFound(String),

    #[error("no start stage defined")]
    NoStartStage,

    #[error("agent error: {0}")]
    Agent(#[from] car_multi::MultiError),

    #[error("cycle limit reached after {0} iterations")]
    CycleLimitReached(u32),

    #[error("stage '{0}' timed out after {1}ms")]
    Timeout(String, u64),
}
