feat: unified error type (#308)
* feat: unified error type * fix: use type id to compare transport type
This commit is contained in:
parent
c74b26b3e3
commit
e615300fea
4 changed files with 286 additions and 161 deletions
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
};
|
||||
|
||||
use rmcp::{
|
||||
ClientHandler, Error as McpError, RoleClient, RoleServer, ServerHandler,
|
||||
ClientHandler, ErrorData as McpError, RoleClient, RoleServer, ServerHandler,
|
||||
model::*,
|
||||
service::{NotificationContext, RequestContext},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rmcp::{
|
||||
Error as McpError, handler::server::tool::Parameters, model::*, schemars, tool, tool_router,
|
||||
ErrorData as McpError, handler::server::tool::Parameters, model::*, schemars, tool, tool_router,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl ServerHandler for Server {
|
|||
&self,
|
||||
request: rmcp::model::SubscribeRequestParam,
|
||||
context: rmcp::service::RequestContext<rmcp::RoleServer>,
|
||||
) -> Result<(), rmcp::Error> {
|
||||
) -> Result<(), rmcp::ErrorData> {
|
||||
let uri = request.uri;
|
||||
let peer = context.peer;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,10 +55,13 @@ impl MyServer {
|
|||
}
|
||||
}
|
||||
#[tool]
|
||||
pub async fn some_progress(meta: Meta, client: Peer<RoleServer>) -> Result<(), rmcp::Error> {
|
||||
pub async fn some_progress(
|
||||
meta: Meta,
|
||||
client: Peer<RoleServer>,
|
||||
) -> Result<(), rmcp::ErrorData> {
|
||||
let progress_token = meta
|
||||
.get_progress_token()
|
||||
.ok_or(rmcp::Error::invalid_params(
|
||||
.ok_or(rmcp::ErrorData::invalid_params(
|
||||
"Progress token is required for this tool",
|
||||
None,
|
||||
))?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue