use thiserror::Error;
pub type SonaTuningResult<T> = Result<T, SonaTuningError>;
#[derive(Debug, Error)]
pub enum SonaTuningError {
#[error("invalid threshold configuration: {0}")]
InvalidThresholdConfig(String),
#[error("trajectory tracking error: {0}")]
TrajectoryError(String),
#[error("learning loop error: {0}")]
LearningLoopError(String),
#[error("pattern not found: {0}")]
PatternNotFound(String),
#[error("knowledge consolidation error: {0}")]
ConsolidationError(String),
#[error("dimension mismatch: expected {expected}, got {actual}")]
DimensionMismatch {
expected: usize,
actual: usize,
},
#[error("SONA engine not initialized")]
EngineNotInitialized,
#[error("regime tracking error: {0}")]
RegimeTrackingError(String),
#[error("loop synchronization error: {0}")]
SyncError(String),
#[error("configuration error: {0}")]
ConfigurationError(String),
#[error("internal SONA tuning error: {0}")]
Internal(String),
}
impl SonaTuningError {
#[must_use]
pub fn dim_mismatch(expected: usize, actual: usize) -> Self {
Self::DimensionMismatch { expected, actual }
}
#[must_use]
pub fn trajectory(msg: impl Into<String>) -> Self {
Self::TrajectoryError(msg.into())
}
#[must_use]
pub fn learning_loop(msg: impl Into<String>) -> Self {
Self::LearningLoopError(msg.into())
}
}