diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/mod.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/mod.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index b35ebd38b..aa3cf1dbd 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs | |||
@@ -23,6 +23,19 @@ use crate::{ | |||
23 | Result, | 23 | Result, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #[derive(Debug, Fail)] | ||
27 | #[fail(display = "Language Server request failed with {}. ({})", code, message)] | ||
28 | pub struct LspError { | ||
29 | pub code: i32, | ||
30 | pub message: String, | ||
31 | } | ||
32 | |||
33 | impl LspError { | ||
34 | pub fn new(code: i32, message: String) -> LspError { | ||
35 | LspError {code, message} | ||
36 | } | ||
37 | } | ||
38 | |||
26 | #[derive(Debug)] | 39 | #[derive(Debug)] |
27 | enum Task { | 40 | enum Task { |
28 | Respond(RawResponse), | 41 | Respond(RawResponse), |
@@ -361,7 +374,10 @@ impl<'a> PoolDispatcher<'a> { | |||
361 | let resp = match f(world, params) { | 374 | let resp = match f(world, params) { |
362 | Ok(resp) => RawResponse::ok::<R>(id, &resp), | 375 | Ok(resp) => RawResponse::ok::<R>(id, &resp), |
363 | Err(e) => { | 376 | Err(e) => { |
364 | RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()) | 377 | match e.downcast::<LspError>() { |
378 | Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message), | ||
379 | Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()) | ||
380 | } | ||
365 | } | 381 | } |
366 | }; | 382 | }; |
367 | let task = Task::Respond(resp); | 383 | let task = Task::Respond(resp); |