use obzenflow_core::StageId;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MessageBusError {
#[error("Failed to send stage command - no stages are listening (are stages initialized?)")]
NoStageReceivers,
}
#[derive(Error, Debug)]
pub enum PipelineSupervisorError {
#[error("Failed to initialize pipeline FSM")]
FsmInitFailed(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("Failed to create stage {stage_id}")]
StageCreationFailed {
stage_id: StageId,
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("Message bus error during {operation}")]
MessageBus {
operation: String,
#[source]
source: MessageBusError,
},
#[error("Pipeline FSM error: {message}")]
PipelineFsmError {
message: String,
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("Journal error: {0}")]
JournalError(String),
}
#[derive(Error, Debug)]
pub enum FlowError {
#[error("Failed to materialize pipeline")]
MaterializationFailed(#[from] PipelineSupervisorError),
#[error("Failed to run pipeline - supervisor not initialized")]
SupervisorNotInitialized,
#[error("Failed to send command to pipeline FSM")]
CommandSendFailed(#[from] MessageBusError),
#[error("Pipeline execution failed")]
ExecutionFailed(#[source] Box<dyn std::error::Error + Send + Sync>),
}
pub type RuntimeResult<T> = Result<T, FlowError>;