From 56df0fc83c753b7fb8829438c8d3017ef1bf450c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Oct 2018 16:03:49 +0300 Subject: Improve logging --- crates/ra_lsp_server/src/main_loop/mod.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index e681062ca..9ddc3fd0b 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -8,7 +8,7 @@ use gen_lsp_server::{ handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, }; use languageserver_types::NumberOrString; -use ra_analysis::{FileId, LibraryData}; +use ra_analysis::{Canceled, FileId, LibraryData}; use rayon::{self, ThreadPool}; use rustc_hash::FxHashSet; use serde::{de::DeserializeOwned, Serialize}; @@ -376,7 +376,7 @@ impl<'a> PoolDispatcher<'a> { Err(e) => { match e.downcast::() { Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message), - Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()) + Err(e) => RawResponse::err(id, ErrorCode::InternalError as i32, format!("{}\n{}", e, e.backtrace())) } } }; @@ -408,14 +408,22 @@ fn update_file_notifications_on_threadpool( pool.spawn(move || { for file_id in subscriptions { match handlers::publish_diagnostics(&world, file_id) { - Err(e) => error!("failed to compute diagnostics: {:?}", e), + Err(e) => { + if !is_canceled(&e) { + error!("failed to compute diagnostics: {:?}", e); + } + }, Ok(params) => { let not = RawNotification::new::(¶ms); sender.send(Task::Notify(not)); } } match handlers::publish_decorations(&world, file_id) { - Err(e) => error!("failed to compute decorations: {:?}", e), + Err(e) => { + if !is_canceled(&e) { + error!("failed to compute decorations: {:?}", e); + } + }, Ok(params) => { let not = RawNotification::new::(¶ms); sender.send(Task::Notify(not)) @@ -432,3 +440,7 @@ fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender) { let not = RawNotification::new::(&msg.to_string()); sender.send(RawMessage::Notification(not)); } + +fn is_canceled(e: &failure::Error) -> bool { + e.downcast_ref::().is_some() +} -- cgit v1.2.3