mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
show error to the user when deserializing config
This commit is contained in:
parent
5fd9a5be09
commit
4dd5afb7fe
3 changed files with 22 additions and 8 deletions
|
@ -11,5 +11,8 @@ mod world;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
caps::server_capabilities, config::ServerConfig, main_loop::main_loop, main_loop::LspError,
|
caps::server_capabilities,
|
||||||
|
config::ServerConfig,
|
||||||
|
main_loop::LspError,
|
||||||
|
main_loop::{main_loop, show_message},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use flexi_logger::{Duplicate, Logger};
|
use flexi_logger::{Duplicate, Logger};
|
||||||
use gen_lsp_server::{run_server, stdio_transport};
|
use gen_lsp_server::{run_server, stdio_transport};
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use ra_lsp_server::{Result, ServerConfig};
|
use ra_lsp_server::{show_message, Result, ServerConfig};
|
||||||
use ra_prof;
|
use ra_prof;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
@ -46,15 +45,23 @@ fn main_inner() -> Result<()> {
|
||||||
.filter(|workspaces| !workspaces.is_empty())
|
.filter(|workspaces| !workspaces.is_empty())
|
||||||
.unwrap_or_else(|| vec![root]);
|
.unwrap_or_else(|| vec![root]);
|
||||||
|
|
||||||
let opts = params
|
let server_config: ServerConfig = params
|
||||||
.initialization_options
|
.initialization_options
|
||||||
.and_then(|v| {
|
.and_then(|v| {
|
||||||
ServerConfig::deserialize(v)
|
serde_json::from_value(v)
|
||||||
.map_err(|e| log::error!("failed to deserialize config: {}", e))
|
.map_err(|e| {
|
||||||
|
log::error!("failed to deserialize config: {}", e);
|
||||||
|
show_message(
|
||||||
|
lsp_types::MessageType::Error,
|
||||||
|
format!("failed to deserialize config: {}", e),
|
||||||
|
s,
|
||||||
|
);
|
||||||
|
})
|
||||||
.ok()
|
.ok()
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s)
|
|
||||||
|
ra_lsp_server::main_loop(workspace_roots, params.capabilities, server_config, r, s)
|
||||||
})?;
|
})?;
|
||||||
log::info!("shutting down IO...");
|
log::info!("shutting down IO...");
|
||||||
threads.join()?;
|
threads.join()?;
|
||||||
|
|
|
@ -617,7 +617,11 @@ fn update_file_notifications_on_threadpool(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<RawMessage>) {
|
pub fn show_message(
|
||||||
|
typ: req::MessageType,
|
||||||
|
message: impl Into<String>,
|
||||||
|
sender: &Sender<RawMessage>,
|
||||||
|
) {
|
||||||
let message = message.into();
|
let message = message.into();
|
||||||
let params = req::ShowMessageParams { typ, message };
|
let params = req::ShowMessageParams { typ, message };
|
||||||
let not = RawNotification::new::<req::ShowMessage>(¶ms);
|
let not = RawNotification::new::<req::ShowMessage>(¶ms);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue