diff --git a/crates/server/src/dispatch.rs b/crates/server/src/dispatch.rs index 381649859f..bfdbd30ca7 100644 --- a/crates/server/src/dispatch.rs +++ b/crates/server/src/dispatch.rs @@ -10,7 +10,7 @@ use drop_bomb::DropBomb; use ::{ Result, req::{ClientRequest, Notification}, - io::{Io, RawMsg, RawResponse, RawRequest, RawNotification}, + io::{RawResponse, RawRequest, RawNotification}, }; pub struct Responder { @@ -113,9 +113,9 @@ pub fn send_notification(params: N::Params) -> RawNotification } } +pub fn unknown_method(id: u64) -> Result { + error_response(id, ErrorCode::MethodNotFound, "unknown method") -pub fn unknown_method(io: &mut Io, raw: RawRequest) -> Result<()> { - error(io, raw.id, ErrorCode::MethodNotFound, "unknown method") } fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result { @@ -135,13 +135,6 @@ fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result Result<()> { - let resp = error_response(id, code, message)?; - io.send(RawMsg::Response(resp)); - Ok(()) -} - - #[allow(unused)] enum ErrorCode { ParseError = -32700, diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index e7b24e53f2..e80b9988d3 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs @@ -102,7 +102,7 @@ fn on_msg( } if let Some(req) = req { error!("unknown method: {:?}", req); - dispatch::unknown_method(io, req)?; + io.send(RawMsg::Response(dispatch::unknown_method(req.id)?)); } } RawMsg::Notification(not) => {