pub enum McpClientError {
Transport(TransportError),
Protocol(ProtocolError),
Session(SessionError),
Auth(String),
Config(String),
Connection(Error),
Json(Error),
Timeout,
ServerError {
code: i32,
message: String,
data: Option<Value>,
},
Generic {
message: String,
},
}Expand description
Comprehensive error type for MCP client operations
Variants§
Transport(TransportError)
Transport-level errors
Protocol(ProtocolError)
Protocol-level errors
Session(SessionError)
Session management errors
Auth(String)
Authentication/authorization errors
Config(String)
Configuration errors
Connection(Error)
Network/connection errors
Json(Error)
JSON parsing errors
Timeout
Timeout errors
ServerError
Server returned an error
Generic
Generic error with context
Implementations§
Source§impl McpClientError
impl McpClientError
Sourcepub fn server_error(
code: i32,
message: impl Into<String>,
data: Option<Value>,
) -> Self
pub fn server_error( code: i32, message: impl Into<String>, data: Option<Value>, ) -> Self
Create a server error from JSON-RPC error response
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if the error is retryable
Sourcepub fn is_protocol_error(&self) -> bool
pub fn is_protocol_error(&self) -> bool
Check if the error is a protocol-level issue
Sourcepub fn is_session_error(&self) -> bool
pub fn is_session_error(&self) -> bool
Check if the error is a session-level issue
Sourcepub fn error_code(&self) -> Option<i32>
pub fn error_code(&self) -> Option<i32>
Get the error code if this is a server error
Trait Implementations§
Source§impl Debug for McpClientError
impl Debug for McpClientError
Source§impl Display for McpClientError
impl Display for McpClientError
Source§impl Error for McpClientError
impl Error for McpClientError
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<Error> for McpClientError
impl From<Error> for McpClientError
Source§impl From<Error> for McpClientError
impl From<Error> for McpClientError
Source§impl From<ProtocolError> for McpClientError
impl From<ProtocolError> for McpClientError
Source§fn from(source: ProtocolError) -> Self
fn from(source: ProtocolError) -> Self
Converts to this type from the input type.
Source§impl From<SessionError> for McpClientError
impl From<SessionError> for McpClientError
Source§fn from(source: SessionError) -> Self
fn from(source: SessionError) -> Self
Converts to this type from the input type.
Source§impl From<TransportError> for McpClientError
impl From<TransportError> for McpClientError
Source§fn from(source: TransportError) -> Self
fn from(source: TransportError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for McpClientError
impl !RefUnwindSafe for McpClientError
impl Send for McpClientError
impl Sync for McpClientError
impl Unpin for McpClientError
impl !UnwindSafe for McpClientError
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> 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.