//! Error types for Blender MCP
use rmcp::ErrorData as McpError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum BlenderError {
#[error("Blender not connected")]
NotConnected,
#[error("Command timeout: {0}")]
Timeout(String),
#[error("Blender error: {0}")]
BlenderError(String),
#[error("Channel error: {0}")]
ChannelError(String),
#[error("Serialization error: {0}")]
SerializationError(#[from] serde_json::Error),
}
impl From<BlenderError> for McpError {
fn from(err: BlenderError) -> Self {
McpError::internal_error(
err.to_string(),
Some(serde_json::json!({ "error": err.to_string() })),
)
}
}
/// Helper to create internal MCP error
pub fn internal_err<T: ToString>(msg: &'static str) -> impl Fn(T) -> McpError {
move |err| McpError::internal_error(msg, Some(serde_json::json!({ "error": err.to_string() })))
}