#[derive(Debug, thiserror::Error)]
pub enum AnomalyError {
#[error("dimension mismatch: expected {expected}, got {got}")]
DimensionMismatch { expected: usize, got: usize },
#[error("empty input")]
EmptyInput,
#[error("model not fitted (call fit() first)")]
NotFitted,
#[error("insufficient training samples: need {need}, got {got}")]
InsufficientSamples { need: usize, got: usize },
#[error("NaN encountered in {context}")]
NanEncountered { context: String },
#[error("invalid k for LOF/kNN: {k}")]
InvalidK { k: usize },
#[error("invalid number of features: {n}")]
InvalidFeatureCount { n: usize },
#[error("invalid layer dims: {msg}")]
InvalidLayerDims { msg: String },
#[error("singular covariance matrix")]
SingularCovariance,
#[error("invalid threshold percentile: {p}")]
InvalidThresholdPercentile { p: f32 },
#[error("feature count mismatch: expected {expected}, got {got}")]
FeatureCountMismatch { expected: usize, got: usize },
#[error("invalid nu parameter for OCSVM: {nu}")]
InvalidNu { nu: f32 },
#[error("convergence failed: {msg}")]
ConvergenceFailed { msg: String },
#[error("internal error: {msg}")]
Internal { msg: String },
}
pub type AnomalyResult<T> = Result<T, AnomalyError>;