59 lines
1.5 KiB
Rust
59 lines
1.5 KiB
Rust
use thiserror::Error;
|
|
|
|
/// Errors that can occur in Graph Neural Network operations
|
|
#[derive(Error, Debug, Clone, PartialEq)]
|
|
pub enum GeomError {
|
|
#[error("Invalid node ID: {0}")]
|
|
InvalidNodeId(usize),
|
|
|
|
#[error("Invalid edge ID: {0}")]
|
|
InvalidEdgeId(usize),
|
|
|
|
#[error("Node not found: {0}")]
|
|
NodeNotFound(usize),
|
|
|
|
#[error("Edge not found: {0}")]
|
|
EdgeNotFound(usize),
|
|
|
|
#[error("Graph is empty")]
|
|
EmptyGraph,
|
|
|
|
#[error("Dimension mismatch: expected {expected}, got {actual}")]
|
|
DimensionMismatch { expected: usize, actual: usize },
|
|
|
|
#[error("Feature shape mismatch: expected {expected:?}, got {actual:?}")]
|
|
FeatureShapeMismatch {
|
|
expected: Vec<usize>,
|
|
actual: Vec<usize>,
|
|
},
|
|
|
|
#[error("Layer initialization failed: {reason}")]
|
|
LayerInitializationFailed { reason: String },
|
|
|
|
#[error("Forward pass failed: {reason}")]
|
|
ForwardPassFailed { reason: String },
|
|
|
|
#[error("Backward pass failed: {reason}")]
|
|
BackwardPassFailed { reason: String },
|
|
|
|
#[error("Message passing failed: {reason}")]
|
|
MessagePassingFailed { reason: String },
|
|
|
|
#[error("Aggregation failed: {reason}")]
|
|
AggregationFailed { reason: String },
|
|
|
|
#[error("Tensor operation error: {0}")]
|
|
TensorError(#[from] rtx_tensor::TensorError),
|
|
|
|
#[error("Runtime error: {0}")]
|
|
RuntimeError(String),
|
|
}
|
|
|
|
impl From<anyhow::Error> for GeomError {
|
|
fn from(error: anyhow::Error) -> Self {
|
|
Self::RuntimeError(error.to_string())
|
|
}
|
|
}
|
|
|
|
pub type Result<T> = std::result::Result<T, GeomError>;
|