pub struct Error {
pub code: ErrorCode,
pub message: String,
pub data: Option<Value>,
}Expand description
Core MCP error type
Fields§
§code: ErrorCodeError code following MCP specification
message: StringHuman-readable error message
data: Option<Value>Optional additional error data
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self
Create a new error with the given code and message
Sourcepub fn with_data(
code: ErrorCode,
message: impl Into<String>,
data: Value,
) -> Self
pub fn with_data( code: ErrorCode, message: impl Into<String>, data: Value, ) -> Self
Create an error with additional data
Sourcepub fn parse_error(message: impl Into<String>) -> Self
pub fn parse_error(message: impl Into<String>) -> Self
Create a parse error
Sourcepub fn invalid_request(message: impl Into<String>) -> Self
pub fn invalid_request(message: impl Into<String>) -> Self
Create an invalid request error
Sourcepub fn method_not_found(method: impl Into<String>) -> Self
pub fn method_not_found(method: impl Into<String>) -> Self
Create a method not found error
Sourcepub fn invalid_params(message: impl Into<String>) -> Self
pub fn invalid_params(message: impl Into<String>) -> Self
Create an invalid params error
Sourcepub fn internal_error(message: impl Into<String>) -> Self
pub fn internal_error(message: impl Into<String>) -> Self
Create an internal error
Sourcepub fn protocol_version_mismatch(
client_version: &str,
server_version: &str,
) -> Self
pub fn protocol_version_mismatch( client_version: &str, server_version: &str, ) -> Self
Create a protocol version mismatch error
Create an authorization error
Sourcepub fn resource_not_found(resource: impl Into<String>) -> Self
pub fn resource_not_found(resource: impl Into<String>) -> Self
Create a resource not found error
Sourcepub fn tool_not_found(tool: impl Into<String>) -> Self
pub fn tool_not_found(tool: impl Into<String>) -> Self
Create a tool not found error
Sourcepub fn validation_error(message: impl Into<String>) -> Self
pub fn validation_error(message: impl Into<String>) -> Self
Create a validation error
Sourcepub fn rate_limit_exceeded(message: impl Into<String>) -> Self
pub fn rate_limit_exceeded(message: impl Into<String>) -> Self
Create a rate limit exceeded error
Sourcepub fn url_elicitation_required(
message: impl Into<String>,
elicitations: Vec<UrlElicitationInfo>,
) -> Self
pub fn url_elicitation_required( message: impl Into<String>, elicitations: Vec<UrlElicitationInfo>, ) -> Self
Create a URL elicitation required error (MCP 2025-11-25)
This error indicates that a request requires URL mode elicitation before it can proceed. The client should present the elicitation URLs to the user and retry after completion.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Error for Error
impl Error for Error
1.30.0§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<CommonError> for Error
impl From<CommonError> for Error
Source§fn from(err: CommonError) -> Self
fn from(err: CommonError) -> Self
Source§impl From<ValidationErrors> for Error
impl From<ValidationErrors> for Error
Source§fn from(err: ValidationErrors) -> Self
fn from(err: ValidationErrors) -> Self
impl StructuralPartialEq for Error
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<E> BackendErrorExt for Ewhere
E: Error,
impl<E> BackendErrorExt for Ewhere
E: Error,
Source§fn backend_error(self, context: &str) -> CommonError
fn backend_error(self, context: &str) -> CommonError
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.