use serde_json::Value;
use crate::error::ErrorResponse;
#[derive(Debug, Clone, Default)]
pub struct McpError {
pub message: String,
pub code: Option<i64>,
pub data: Option<Value>,
pub response: Option<ErrorResponse>,
}
impl McpError {
pub fn new(message: impl Into<String>) -> McpError {
McpError {
message: message.into(),
..Default::default()
}
}
}
impl std::fmt::Display for McpError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.message)
}
}
impl std::error::Error for McpError {}
impl From<McpError> for crate::Error {
fn from(error: McpError) -> Self {
crate::Error::Mcp(Box::new(error))
}
}