47 lines
1.0 KiB
Rust
47 lines
1.0 KiB
Rust
//! Error types for PIDDM demo.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use thiserror::Error;
|
|
|
|
/// Errors that can occur in the PIDDM demo.
|
|
#[derive(Debug, Clone, Error, Serialize, Deserialize)]
|
|
pub enum PiddmError {
|
|
/// Invalid configuration parameter.
|
|
#[error("Invalid configuration: {0}")]
|
|
InvalidConfig(String),
|
|
|
|
/// Training error.
|
|
#[error("Training error: {0}")]
|
|
TrainingError(String),
|
|
|
|
/// Sampling/inference error.
|
|
#[error("Sampling error: {0}")]
|
|
SamplingError(String),
|
|
|
|
/// Model not loaded.
|
|
#[error("Model not loaded")]
|
|
ModelNotLoaded,
|
|
|
|
/// IO error.
|
|
#[error("IO error: {0}")]
|
|
IoError(String),
|
|
|
|
/// Backend error.
|
|
#[error("Backend error: {0}")]
|
|
BackendError(String),
|
|
}
|
|
|
|
/// Result type for PIDDM operations.
|
|
pub type PiddmResult<T> = Result<T, PiddmError>;
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_error_display() {
|
|
let err = PiddmError::InvalidConfig("bad value".to_string());
|
|
assert!(err.to_string().contains("Invalid configuration"));
|
|
}
|
|
}
|