#[non_exhaustive]pub enum ClientInitializeError {
ExpectedInitResponse(Option<ServerJsonRpcMessage>),
ExpectedInitResult(Option<ServerResult>),
ConflictInitResponseId(RequestId, RequestId),
UncorrelatedErrorResponse {
expected: RequestId,
received: RequestId,
},
ConnectionClosed(String),
TransportError {
error: DynamicTransportError,
context: Cow<'static, str>,
},
JsonRpcError(ErrorData),
NoCompatibleProtocolVersion {
client_supported: Vec<ProtocolVersion>,
server_supported: Vec<ProtocolVersion>,
},
NoPreferredProtocolVersion,
Cancelled,
LegacyFallbackFailed {
discover: Box<ClientInitializeError>,
fallback: Box<ClientInitializeError>,
},
}Available on crate feature
client and (crate features client or server) only.Expand description
It represents the error that may occur when serving the client.
if you want to handle the error, you can use serve_client_with_ct or serve_client with Result<RunningService<RoleClient, S>, ClientError>
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ExpectedInitResponse(Option<ServerJsonRpcMessage>)
ExpectedInitResult(Option<ServerResult>)
ConflictInitResponseId(RequestId, RequestId)
ConnectionClosed(String)
TransportError
JsonRpcError(ErrorData)
NoCompatibleProtocolVersion
NoPreferredProtocolVersion
Cancelled
LegacyFallbackFailed
Implementations§
Source§impl ClientInitializeError
impl ClientInitializeError
pub fn transport<T: Transport<RoleClient> + 'static>( error: T::Error, context: impl Into<Cow<'static, str>>, ) -> Self
Sourcepub fn auth_challenge(&self) -> Option<&str>
Available on crate feature transport-streamable-http-client only.
pub fn auth_challenge(&self) -> Option<&str>
transport-streamable-http-client only.The WWW-Authenticate challenge from the 401/403 the transport hit
during initialization, if that is why initialization failed.
This is the trigger of the reactive OAuth flow: feed the challenge to
AuthorizationRequest::with_challenge to authorize, then reconnect.
Returns whether client initialization failed because authorization is required.
This covers both missing or expired local OAuth authorization and an HTTP authorization challenge from the MCP server.
Trait Implementations§
Source§impl Debug for ClientInitializeError
impl Debug for ClientInitializeError
Source§impl Display for ClientInitializeError
impl Display for ClientInitializeError
Source§impl Error for ClientInitializeError
impl Error for ClientInitializeError
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<ClientInitializeError> for RmcpError
impl From<ClientInitializeError> for RmcpError
Source§fn from(source: ClientInitializeError) -> Self
fn from(source: ClientInitializeError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for ClientInitializeError
impl !UnwindSafe for ClientInitializeError
impl Freeze for ClientInitializeError
impl Send for ClientInitializeError
impl Sync for ClientInitializeError
impl Unpin for ClientInitializeError
impl UnsafeUnpin for ClientInitializeError
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