excel_mcp_server/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum ExcelMcpError {
9 NotFound(String),
11 InvalidInput(String),
13 EngineUnsupported(String),
15 CapacityExceeded(String),
17 IoError(String),
19 ParseError(String),
21 Evicted(String),
23}
24
25impl fmt::Display for ExcelMcpError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 ExcelMcpError::NotFound(msg) => write!(f, "Not found: {msg}"),
29 ExcelMcpError::InvalidInput(msg) => write!(f, "Invalid input: {msg}"),
30 ExcelMcpError::EngineUnsupported(msg) => write!(f, "Engine unsupported: {msg}"),
31 ExcelMcpError::CapacityExceeded(msg) => write!(f, "Capacity exceeded: {msg}"),
32 ExcelMcpError::IoError(msg) => write!(f, "IO error: {msg}"),
33 ExcelMcpError::ParseError(msg) => write!(f, "Parse error: {msg}"),
34 ExcelMcpError::Evicted(msg) => write!(f, "Evicted: {msg}"),
35 }
36 }
37}
38
39impl std::error::Error for ExcelMcpError {}
40
41impl From<std::io::Error> for ExcelMcpError {
42 fn from(err: std::io::Error) -> Self {
43 ExcelMcpError::IoError(err.to_string())
44 }
45}
46
47impl From<serde_json::Error> for ExcelMcpError {
48 fn from(err: serde_json::Error) -> Self {
49 ExcelMcpError::ParseError(err.to_string())
50 }
51}