diff options
author | Aleksey Kladov <[email protected]> | 2020-09-29 19:08:27 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-09-29 19:20:47 +0100 |
commit | d3a2b21a8c34c7b7eea0a001a1412992e3ed2cb7 (patch) | |
tree | 0f965a835c179637f6df293cef010134f283cfea /crates/rust-analyzer | |
parent | e315fd9bb0e0647ab8b0e118d264d2103e271586 (diff) |
Add panic_context module for better panic messages
Diffstat (limited to 'crates/rust-analyzer')
-rw-r--r-- | crates/rust-analyzer/src/dispatch.rs | 7 |
1 files changed, 5 insertions, 2 deletions
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 @@ | |||
1 | //! A visitor for downcasting arbitrary request (JSON) into a specific type. | 1 | //! A visitor for downcasting arbitrary request (JSON) into a specific type. |
2 | use std::panic; | 2 | use std::{fmt, panic}; |
3 | 3 | ||
4 | use serde::{de::DeserializeOwned, Serialize}; | 4 | use serde::{de::DeserializeOwned, Serialize}; |
5 | 5 | ||
@@ -49,7 +49,7 @@ impl<'a> RequestDispatcher<'a> { | |||
49 | ) -> Result<&mut Self> | 49 | ) -> Result<&mut Self> |
50 | where | 50 | where |
51 | R: lsp_types::request::Request + 'static, | 51 | R: lsp_types::request::Request + 'static, |
52 | R::Params: DeserializeOwned + Send + 'static, | 52 | R::Params: DeserializeOwned + Send + fmt::Debug + 'static, |
53 | R::Result: Serialize + 'static, | 53 | R::Result: Serialize + 'static, |
54 | { | 54 | { |
55 | let (id, params) = match self.parse::<R>() { | 55 | let (id, params) = match self.parse::<R>() { |
@@ -61,7 +61,10 @@ impl<'a> RequestDispatcher<'a> { | |||
61 | 61 | ||
62 | self.global_state.task_pool.handle.spawn({ | 62 | self.global_state.task_pool.handle.spawn({ |
63 | let world = self.global_state.snapshot(); | 63 | let world = self.global_state.snapshot(); |
64 | |||
64 | move || { | 65 | move || { |
66 | let _ctx = | ||
67 | stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); | ||
65 | let result = f(world, params); | 68 | let result = f(world, params); |
66 | Task::Response(result_to_response::<R>(id, result)) | 69 | Task::Response(result_to_response::<R>(id, result)) |
67 | } | 70 | } |