diff options
Diffstat (limited to 'crates/server')
-rw-r--r-- | crates/server/src/dispatch.rs | 13 | ||||
-rw-r--r-- | crates/server/src/main_loop/mod.rs | 2 |
2 files changed, 4 insertions, 11 deletions
diff --git a/crates/server/src/dispatch.rs b/crates/server/src/dispatch.rs index 381649859..bfdbd30ca 100644 --- a/crates/server/src/dispatch.rs +++ b/crates/server/src/dispatch.rs | |||
@@ -10,7 +10,7 @@ use drop_bomb::DropBomb; | |||
10 | use ::{ | 10 | use ::{ |
11 | Result, | 11 | Result, |
12 | req::{ClientRequest, Notification}, | 12 | req::{ClientRequest, Notification}, |
13 | io::{Io, RawMsg, RawResponse, RawRequest, RawNotification}, | 13 | io::{RawResponse, RawRequest, RawNotification}, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | pub struct Responder<R: ClientRequest> { | 16 | pub struct Responder<R: ClientRequest> { |
@@ -113,9 +113,9 @@ pub fn send_notification<N>(params: N::Params) -> RawNotification | |||
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | pub fn unknown_method(id: u64) -> Result<RawResponse> { | ||
117 | error_response(id, ErrorCode::MethodNotFound, "unknown method") | ||
116 | 118 | ||
117 | pub fn unknown_method(io: &mut Io, raw: RawRequest) -> Result<()> { | ||
118 | error(io, raw.id, ErrorCode::MethodNotFound, "unknown method") | ||
119 | } | 119 | } |
120 | 120 | ||
121 | fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<RawResponse> { | 121 | fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<RawResponse> { |
@@ -135,13 +135,6 @@ fn error_response(id: u64, code: ErrorCode, message: &'static str) -> Result<Raw | |||
135 | Ok(resp) | 135 | Ok(resp) |
136 | } | 136 | } |
137 | 137 | ||
138 | fn error(io: &mut Io, id: u64, code: ErrorCode, message: &'static str) -> Result<()> { | ||
139 | let resp = error_response(id, code, message)?; | ||
140 | io.send(RawMsg::Response(resp)); | ||
141 | Ok(()) | ||
142 | } | ||
143 | |||
144 | |||
145 | #[allow(unused)] | 138 | #[allow(unused)] |
146 | enum ErrorCode { | 139 | enum ErrorCode { |
147 | ParseError = -32700, | 140 | ParseError = -32700, |
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index e7b24e53f..e80b9988d 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs | |||
@@ -102,7 +102,7 @@ fn on_msg( | |||
102 | } | 102 | } |
103 | if let Some(req) = req { | 103 | if let Some(req) = req { |
104 | error!("unknown method: {:?}", req); | 104 | error!("unknown method: {:?}", req); |
105 | dispatch::unknown_method(io, req)?; | 105 | io.send(RawMsg::Response(dispatch::unknown_method(req.id)?)); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | RawMsg::Notification(not) => { | 108 | RawMsg::Notification(not) => { |