pub enum Error {
ConnectionFailed {
server: String,
source: Box<dyn Error + Send + Sync>,
},
SecurityViolation {
reason: String,
},
ResourceNotFound {
resource: String,
},
ConfigError {
message: String,
},
Timeout {
operation: String,
duration_secs: u64,
},
SerializationError {
message: String,
source: Option<Error>,
},
InvalidArgument(String),
ValidationError {
field: String,
reason: String,
},
ScriptGenerationError {
tool: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
}Expand description
Main error type for MCP Code Execution.
All errors in the system use this type, providing consistent error handling across all crates in the workspace.
Variants§
ConnectionFailed
MCP server connection failed.
This error occurs when attempting to connect to an MCP server and the connection fails due to network issues, authentication failures, or server unavailability.
Fields
SecurityViolation
Security policy violation.
Raised when an operation violates configured security policies, such as attempting to access forbidden resources or exceeding resource limits.
ResourceNotFound
Resource not found error.
Occurs when attempting to access a resource (file, tool, server) that does not exist.
ConfigError
Configuration error.
Raised when configuration is invalid, missing required fields, or contains contradictory settings.
Timeout
Timeout error.
Occurs when an operation exceeds its configured timeout limit.
Fields
SerializationError
Serialization/deserialization error.
Raised when JSON or other data format conversion fails.
Fields
InvalidArgument(String)
Invalid argument error.
Raised when CLI arguments or function parameters are invalid.
ValidationError
Validation error for domain types.
Raised when creating or validating domain types like SkillName,
SkillDescription, etc. that have specific format requirements.
Fields
ScriptGenerationError
Script generation failed.
Raised when generating TypeScript scripts from tool schemas fails.
Implementations§
Source§impl Error
impl Error
Sourcepub const fn is_connection_error(&self) -> bool
pub const fn is_connection_error(&self) -> bool
Returns true if this is a connection error.
§Examples
use mcp_execution_core::Error;
let err = Error::ConnectionFailed {
server: "test".to_string(),
source: "connection refused".into(),
};
assert!(err.is_connection_error());Sourcepub const fn is_security_error(&self) -> bool
pub const fn is_security_error(&self) -> bool
Returns true if this is a security violation error.
§Examples
use mcp_execution_core::Error;
let err = Error::SecurityViolation {
reason: "Unauthorized access".to_string(),
};
assert!(err.is_security_error());Sourcepub const fn is_not_found(&self) -> bool
pub const fn is_not_found(&self) -> bool
Returns true if this is a resource not found error.
§Examples
use mcp_execution_core::Error;
let err = Error::ResourceNotFound {
resource: "tool:example".to_string(),
};
assert!(err.is_not_found());Sourcepub const fn is_config_error(&self) -> bool
pub const fn is_config_error(&self) -> bool
Returns true if this is a configuration error.
§Examples
use mcp_execution_core::Error;
let err = Error::ConfigError {
message: "Invalid port".to_string(),
};
assert!(err.is_config_error());Sourcepub const fn is_timeout(&self) -> bool
pub const fn is_timeout(&self) -> bool
Returns true if this is a timeout error.
§Examples
use mcp_execution_core::Error;
let err = Error::Timeout {
operation: "execute_code".to_string(),
duration_secs: 30,
};
assert!(err.is_timeout());Sourcepub const fn is_validation_error(&self) -> bool
pub const fn is_validation_error(&self) -> bool
Returns true if this is a validation error.
§Examples
use mcp_execution_core::Error;
let err = Error::ValidationError {
field: "skill_name".to_string(),
reason: "Invalid characters".to_string(),
};
assert!(err.is_validation_error());Sourcepub const fn is_script_generation_error(&self) -> bool
pub const fn is_script_generation_error(&self) -> bool
Returns true if this is a script generation error.
§Examples
use mcp_execution_core::Error;
let err = Error::ScriptGenerationError {
tool: "send_message".to_string(),
message: "Template rendering failed".to_string(),
source: None,
};
assert!(err.is_script_generation_error());