use thiserror::Error;
use crate::node::NodeId;
pub type GraphResult<T> = Result<T, GraphError>;
#[derive(Debug, Error)]
pub enum GraphError {
#[error("node {0:?} not found in graph")]
NodeNotFound(NodeId),
#[error("adding edge from {from:?} to {to:?} would create a cycle")]
CycleDetected { from: NodeId, to: NodeId },
#[error("graph is empty")]
EmptyGraph,
#[error("buffer shape mismatch at node {node:?}: expected {expected} bytes, got {got} bytes")]
BufferSizeMismatch {
node: NodeId,
expected: usize,
got: usize,
},
#[error("nodes {a:?} and {b:?} cannot be fused: {reason}")]
FusionNotPossible {
a: NodeId,
b: NodeId,
reason: &'static str,
},
#[error("memory planning failed: {0}")]
MemoryPlanningFailed(String),
#[error("stream partitioning failed: {0}")]
StreamPartitioningFailed(String),
#[error("invalid execution plan: {0}")]
InvalidPlan(String),
#[error("graph validation failed: {0}")]
ValidationFailed(String),
#[error("PTX codegen failed for fusion group {group}: {reason}")]
PtxCodegenFailed { group: usize, reason: String },
#[error("internal graph error: {0}")]
Internal(String),
}