//! Error types for artifact detection. use thiserror::Error; /// Error type for artifact detection operations #[derive(Error, Debug)] pub enum ArtifactError { /// Model loading error #[error("Model error: {0}")] Model(String), /// ONNX inference error #[error("Inference error: {0}")] Inference(String), /// Input validation error #[error("Input error: {0}")] Input(String), /// Dimension mismatch #[error("Dimension mismatch: {0}")] DimensionMismatch(String), /// Explainability error #[error("Explainability error: {0}")] Explainability(String), /// Download error #[error("Download error: {0}")] Download(String), /// Configuration error #[error("Configuration error: {0}")] Config(String), /// IO error #[error("IO error: {0}")] Io(#[from] std::io::Error), /// ONNX error (from rtx-onnx) #[error("ONNX error: {0}")] Onnx(String), /// Tensor error #[error("Tensor error: {0}")] Tensor(String), } impl From for ArtifactError { fn from(err: rtx_onnx::OnnxError) -> Self { Self::Onnx(err.to_string()) } } impl From for ArtifactError { fn from(err: rtx_tensor::TensorError) -> Self { Self::Tensor(err.to_string()) } } /// Result type for artifact operations pub type ArtifactResult = Result; #[cfg(test)] mod tests { use super::*; #[test] fn test_error_display() { let err = ArtifactError::Model("Model not found".to_string()); assert!(err.to_string().contains("Model not found")); } #[test] fn test_dimension_mismatch_error() { let err = ArtifactError::DimensionMismatch("Expected 64 channels, got 32".to_string()); assert!(err.to_string().contains("64 channels")); } }