use std::collections::{BTreeMap, HashMap};
use thiserror::Error;
pub type Result<T> = std::result::Result<T, AIOpsError>;
#[derive(Error, Debug, Clone, PartialEq)]
pub enum AIOpsError {
#[error("Model error: {0}")]
Model(String),
#[error("Data collection error: {0}")]
DataCollection(String),
#[error("Prediction error: {0}")]
Prediction(String),
#[error("Optimization error: {0}")]
Optimization(String),
#[error("Resource allocation error: {0}")]
Allocation(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("AIOps error: {0}")]
Other(String),
}
impl AIOpsError {
pub fn model<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::Model(msg.to_string())
}
pub fn data_collection<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::DataCollection(msg.to_string())
}
pub fn prediction<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::Prediction(msg.to_string())
}
pub fn optimization<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::Optimization(msg.to_string())
}
pub fn allocation<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::Allocation(msg.to_string())
}
pub fn config<T: std::fmt::Display>(msg: T) -> Self {
AIOpsError::Config(msg.to_string())
}
}