pub struct Error {
pub code: ErrorCode,
pub message: String,
pub data: Option<Value>,
}
Expand description
Re-export commonly used types Core MCP error type
Fields§
§code: ErrorCode
Error code following MCP specification
message: String
Human-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>) -> Error
pub fn new(code: ErrorCode, message: impl Into<String>) -> Error
Create a new error with the given code and message
Sourcepub fn with_data(
code: ErrorCode,
message: impl Into<String>,
data: Value,
) -> Error
pub fn with_data( code: ErrorCode, message: impl Into<String>, data: Value, ) -> Error
Create an error with additional data
Sourcepub fn parse_error(message: impl Into<String>) -> Error
pub fn parse_error(message: impl Into<String>) -> Error
Create a parse error
Sourcepub fn invalid_request(message: impl Into<String>) -> Error
pub fn invalid_request(message: impl Into<String>) -> Error
Create an invalid request error
Sourcepub fn method_not_found(method: impl Into<String>) -> Error
pub fn method_not_found(method: impl Into<String>) -> Error
Create a method not found error
Sourcepub fn invalid_params(message: impl Into<String>) -> Error
pub fn invalid_params(message: impl Into<String>) -> Error
Create an invalid params error
Sourcepub fn internal_error(message: impl Into<String>) -> Error
pub fn internal_error(message: impl Into<String>) -> Error
Create an internal error
Sourcepub fn protocol_version_mismatch(
client_version: &str,
server_version: &str,
) -> Error
pub fn protocol_version_mismatch( client_version: &str, server_version: &str, ) -> Error
Create a protocol version mismatch error
Create an authorization error
Sourcepub fn resource_not_found(resource: impl Into<String>) -> Error
pub fn resource_not_found(resource: impl Into<String>) -> Error
Create a resource not found error
Sourcepub fn tool_not_found(tool: impl Into<String>) -> Error
pub fn tool_not_found(tool: impl Into<String>) -> Error
Create a tool not found error
Sourcepub fn validation_error(message: impl Into<String>) -> Error
pub fn validation_error(message: impl Into<String>) -> Error
Create a validation error
Sourcepub fn rate_limit_exceeded(message: impl Into<String>) -> Error
pub fn rate_limit_exceeded(message: impl Into<String>) -> Error
Create a rate limit exceeded error
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Error, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Error, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<ValidationErrors> for Error
impl From<ValidationErrors> for Error
Source§fn from(err: ValidationErrors) -> Error
fn from(err: ValidationErrors) -> Error
Converts to this type from the input type.
Source§impl Serialize for Error
impl Serialize for Error
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP