From d3a2b21a8c34c7b7eea0a001a1412992e3ed2cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 29 Sep 2020 20:08:27 +0200 Subject: Add panic_context module for better panic messages --- crates/rust-analyzer/src/dispatch.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/rust-analyzer') diff --git a/crates/rust-analyzer/src/dispatch.rs b/crates/rust-analyzer/src/dispatch.rs index 891fdb96d..36f0c1d52 100644 --- a/crates/rust-analyzer/src/dispatch.rs +++ b/crates/rust-analyzer/src/dispatch.rs @@ -1,5 +1,5 @@ //! A visitor for downcasting arbitrary request (JSON) into a specific type. -use std::panic; +use std::{fmt, panic}; use serde::{de::DeserializeOwned, Serialize}; @@ -49,7 +49,7 @@ impl<'a> RequestDispatcher<'a> { ) -> Result<&mut Self> where R: lsp_types::request::Request + 'static, - R::Params: DeserializeOwned + Send + 'static, + R::Params: DeserializeOwned + Send + fmt::Debug + 'static, R::Result: Serialize + 'static, { let (id, params) = match self.parse::() { @@ -61,7 +61,10 @@ impl<'a> RequestDispatcher<'a> { self.global_state.task_pool.handle.spawn({ let world = self.global_state.snapshot(); + move || { + let _ctx = + stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); let result = f(world, params); Task::Response(result_to_response::(id, result)) } -- cgit v1.2.3