From 7ae6cad52ed001a903577e30fb71e346fd831af7 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 11 May 2022 11:00:55 +0900 Subject: Don't panic on LSP parsing errors This made sense initially when the implementation was still new (so we got user reports more frequently), but a parsing error now generally signifies a language server isn't properly implementing the spec. --- helix-term/src/application.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 91caade7..2dfccf04 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -399,8 +399,14 @@ impl Application { match call { Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => { let notification = match Notification::parse(&method, params) { - Some(notification) => notification, - None => return, + Ok(notification) => notification, + Err(err) => { + log::error!( + "received malformed notification from Language Server: {}", + err + ); + return; + } }; match notification { @@ -613,9 +619,17 @@ impl Application { method, params, id, .. }) => { let call = match MethodCall::parse(&method, params) { - Some(call) => call, - None => { - error!("Method not found {}", method); + Ok(call) => call, + Err(helix_lsp::Error::Unhandled) => { + error!("Language Server: Method not found {}", method); + return; + } + Err(err) => { + log::error!( + "received malformed method call from Language Server: {}: {}", + method, + err + ); return; } }; -- cgit v1.2.3-70-g09d2