Error

Enum Error 

Source
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

§server: String

Name or identifier of the server that failed to connect

§source: Box<dyn Error + Send + Sync>

Underlying error cause

§

SecurityViolation

Security policy violation.

Raised when an operation violates configured security policies, such as attempting to access forbidden resources or exceeding resource limits.

Fields

§reason: String

Description of the security violation

§

ResourceNotFound

Resource not found error.

Occurs when attempting to access a resource (file, tool, server) that does not exist.

Fields

§resource: String

Identifier of the missing resource

§

ConfigError

Configuration error.

Raised when configuration is invalid, missing required fields, or contains contradictory settings.

Fields

§message: String

Description of the configuration problem

§

Timeout

Timeout error.

Occurs when an operation exceeds its configured timeout limit.

Fields

§operation: String

Name of the operation that timed out

§duration_secs: u64

Duration in seconds before timeout occurred

§

SerializationError

Serialization/deserialization error.

Raised when JSON or other data format conversion fails.

Fields

§message: String

Description of the serialization failure

§source: Option<Error>

Underlying serde error

§

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

§field: String

The field that failed validation

§reason: String

Detailed reason for the validation failure

§

ScriptGenerationError

Script generation failed.

Raised when generating TypeScript scripts from tool schemas fails.

Fields

§tool: String

The tool name that failed to generate

§message: String

Description of the generation failure

§source: Option<Box<dyn Error + Send + Sync>>

Optional underlying error

Implementations§

Source§

impl Error

Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.