aboutsummaryrefslogtreecommitdiff
path: root/crates/gen_lsp_server/src/lib.rs
diff options
context:
space:
mode:
authorMuhammad Mominul Huque <[email protected]>2019-06-14 20:03:17 +0100
committerMuhammad Mominul Huque <[email protected]>2019-06-14 20:03:17 +0100
commita931fb1ef633473e272bb3f9ba86968dd90f44a7 (patch)
treec412d82041686c7cd8033ff0bdc7ae5545c50cea /crates/gen_lsp_server/src/lib.rs
parent84b66107828365d02fd29641fe32b3c42f036864 (diff)
Get rid of failure: gen_lsp_server
Diffstat (limited to 'crates/gen_lsp_server/src/lib.rs')
-rw-r--r--crates/gen_lsp_server/src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 1cd5a3a7c..7643dcacc 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -54,7 +54,7 @@
54//! } 54//! }
55//! ``` 55//! ```
56 56
57use failure::{bail, format_err}; 57use std::error::Error;
58 58
59mod msg; 59mod msg;
60mod stdio; 60mod stdio;
@@ -66,7 +66,7 @@ use lsp_types::{
66 InitializeParams, InitializeResult, ServerCapabilities, 66 InitializeParams, InitializeResult, ServerCapabilities,
67}; 67};
68 68
69pub type Result<T> = ::std::result::Result<T, failure::Error>; 69pub type Result<T> = ::std::result::Result<T, Box<dyn Error + Send + Sync>>;
70pub use crate::{ 70pub use crate::{
71 msg::{ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, RawResponseError}, 71 msg::{ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, RawResponseError},
72 stdio::{stdio_transport, Threads}, 72 stdio::{stdio_transport, Threads},
@@ -92,8 +92,8 @@ pub fn run_server(
92 match receiver.recv() { 92 match receiver.recv() {
93 Ok(RawMessage::Notification(n)) => n 93 Ok(RawMessage::Notification(n)) => n
94 .cast::<Exit>() 94 .cast::<Exit>()
95 .map_err(|n| format_err!("unexpected notification during shutdown: {:?}", n))?, 95 .map_err(|n| format!("unexpected notification during shutdown: {:?}", n))?,
96 m => bail!("unexpected message during shutdown: {:?}", m), 96 m => Err(format!("unexpected message during shutdown: {:?}", m))?,
97 } 97 }
98 log::info!("lsp server shutdown complete"); 98 log::info!("lsp server shutdown complete");
99 Ok(()) 99 Ok(())
@@ -118,19 +118,19 @@ fn initialize(
118) -> Result<InitializeParams> { 118) -> Result<InitializeParams> {
119 let (id, params) = match receiver.recv() { 119 let (id, params) = match receiver.recv() {
120 Ok(RawMessage::Request(req)) => match req.cast::<Initialize>() { 120 Ok(RawMessage::Request(req)) => match req.cast::<Initialize>() {
121 Err(req) => bail!("expected initialize request, got {:?}", req), 121 Err(req) => Err(format!("expected initialize request, got {:?}", req))?,
122 Ok(req) => req, 122 Ok(req) => req,
123 }, 123 },
124 msg => bail!("expected initialize request, got {:?}", msg), 124 msg => Err(format!("expected initialize request, got {:?}", msg))?,
125 }; 125 };
126 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps }); 126 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps });
127 sender.send(RawMessage::Response(resp)).unwrap(); 127 sender.send(RawMessage::Response(resp)).unwrap();
128 match receiver.recv() { 128 match receiver.recv() {
129 Ok(RawMessage::Notification(n)) => { 129 Ok(RawMessage::Notification(n)) => {
130 n.cast::<Initialized>() 130 n.cast::<Initialized>()
131 .map_err(|_| format_err!("expected initialized notification"))?; 131 .map_err(|_| "expected initialized notification")?;
132 } 132 }
133 _ => bail!("expected initialized notification"), 133 _ => Err(format!("expected initialized notification"))?,
134 } 134 }
135 Ok(params) 135 Ok(params)
136} 136}