use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ExcelMcpError {
NotFound(String),
InvalidInput(String),
EngineUnsupported(String),
CapacityExceeded(String),
IoError(String),
ParseError(String),
Evicted(String),
}
impl fmt::Display for ExcelMcpError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ExcelMcpError::NotFound(msg) => write!(f, "Not found: {msg}"),
ExcelMcpError::InvalidInput(msg) => write!(f, "Invalid input: {msg}"),
ExcelMcpError::EngineUnsupported(msg) => write!(f, "Engine unsupported: {msg}"),
ExcelMcpError::CapacityExceeded(msg) => write!(f, "Capacity exceeded: {msg}"),
ExcelMcpError::IoError(msg) => write!(f, "IO error: {msg}"),
ExcelMcpError::ParseError(msg) => write!(f, "Parse error: {msg}"),
ExcelMcpError::Evicted(msg) => write!(f, "Evicted: {msg}"),
}
}
}
impl std::error::Error for ExcelMcpError {}
impl From<std::io::Error> for ExcelMcpError {
fn from(err: std::io::Error) -> Self {
ExcelMcpError::IoError(err.to_string())
}
}
impl From<serde_json::Error> for ExcelMcpError {
fn from(err: serde_json::Error) -> Self {
ExcelMcpError::ParseError(err.to_string())
}
}