codeprism_mcp_server/
error.rs1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Error, Debug)]
10pub enum Error {
11 #[error("Configuration error: {0}")]
13 Config(#[from] config::ConfigError),
14
15 #[error("IO error: {0}")]
17 Io(#[from] std::io::Error),
18
19 #[error("JSON error: {0}")]
21 Json(#[from] serde_json::Error),
22
23 #[error("TOML error: {0}")]
25 Toml(#[from] toml::de::Error),
26
27 #[error("TOML serialization error: {0}")]
29 TomlSer(#[from] toml::ser::Error),
30
31 #[error("YAML error: {0}")]
33 Yaml(#[from] serde_yaml::Error),
34
35 #[error("MCP protocol error: {0}")]
37 Protocol(String),
38
39 #[error("Server initialization error: {0}")]
41 ServerInit(String),
42
43 #[error("Tool execution error: {0}")]
45 ToolExecution(String),
46
47 #[error("Internal error: {0}")]
49 Internal(#[from] anyhow::Error),
50}
51
52impl Error {
53 pub fn protocol(msg: impl Into<String>) -> Self {
55 Self::Protocol(msg.into())
56 }
57
58 pub fn server_init(msg: impl Into<String>) -> Self {
60 Self::ServerInit(msg.into())
61 }
62
63 pub fn tool_execution(msg: impl Into<String>) -> Self {
65 Self::ToolExecution(msg.into())
66 }
67}