pub struct McpError {
pub error_type: ErrorType,
pub code: String,
pub message: String,
pub details: HashMap<String, Value>,
pub cause: Option<Box<dyn Error + Send + Sync>>,
}Expand description
Rich MCP error with context
Fields§
§error_type: ErrorTypeError type
code: StringError code (string identifier)
message: StringError message
details: HashMap<String, Value>Additional details
cause: Option<Box<dyn Error + Send + Sync>>Underlying cause
Implementations§
Source§impl McpError
impl McpError
Sourcepub fn to_jsonrpc(&self) -> JsonRpcError
pub fn to_jsonrpc(&self) -> JsonRpcError
Convert to JSON-RPC error
Sourcepub fn builder(
error_type: ErrorType,
code: impl Into<String>,
) -> McpErrorBuilder
pub fn builder( error_type: ErrorType, code: impl Into<String>, ) -> McpErrorBuilder
Start building a new error
Sourcepub fn validation(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn validation(code: impl Into<String>, message: impl Into<String>) -> Self
Create a validation error
Sourcepub fn not_found(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn not_found(code: impl Into<String>, message: impl Into<String>) -> Self
Create a not found error
Sourcepub fn internal(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn internal(code: impl Into<String>, message: impl Into<String>) -> Self
Create an internal 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 not_implemented(message: impl Into<String>) -> Self
pub fn not_implemented(message: impl Into<String>) -> Self
Create a not implemented error
Sourcepub fn rate_limited(message: impl Into<String>) -> Self
pub fn rate_limited(message: impl Into<String>) -> Self
Create a rate limited error
Trait Implementations§
Source§impl Error for McpError
impl Error for McpError
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()
Auto Trait Implementations§
impl Freeze for McpError
impl !RefUnwindSafe for McpError
impl Send for McpError
impl Sync for McpError
impl Unpin for McpError
impl !UnwindSafe for McpError
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