on master help sign in
prevent panic when receiving malformed LSP PublishDiagnostic (#2160)
449d1dfMichael Davis
helix-lsp/src/lib.rs+7−1
@@ -276,7 +276,13 @@ impl Notification {
276 lsp::notification::PublishDiagnostics::METHOD => {
276 lsp::notification::PublishDiagnostics::METHOD => {
277 let params: lsp::PublishDiagnosticsParams = params
277 let params: lsp::PublishDiagnosticsParams = params
278 .parse()
278 .parse()
279− .expect("Failed to parse PublishDiagnostics params");
279+ .map_err(|err| {
280+ log::error!(
281+ "received malformed PublishDiagnostic from Language Server: {}",
282+ err
283+ )
284+ })
285+ .ok()?;
280
286
281 // TODO: need to loop over diagnostics and distinguish them by URI
287 // TODO: need to loop over diagnostics and distinguish them by URI
282 Self::PublishDiagnostics(params)
288 Self::PublishDiagnostics(params)