mirror of
https://github.com/kbwo/testing-language-server.git
synced 2025-08-03 15:18:16 +00:00
fix: handle errors correctly
This commit is contained in:
parent
c61aaac03e
commit
c5fe76295d
1 changed files with 12 additions and 8 deletions
20
src/main.rs
20
src/main.rs
|
@ -82,13 +82,15 @@ fn main_loop(server: &mut TestingLS) -> Result<(), LSError> {
|
|||
|
||||
if let Some(method) = method {
|
||||
match *method {
|
||||
"initialized" | "$/cancelRequest" => {}
|
||||
"$/cancelRequest" => {}
|
||||
"initialized" => {
|
||||
is_workspace_checked = true;
|
||||
server.diagnose_workspace()?;
|
||||
}
|
||||
"initialize" => {
|
||||
let initialize_params = InitializeParams::deserialize(params)?;
|
||||
let id = value["id"].as_i64().unwrap();
|
||||
server.initialize(id, initialize_params)?;
|
||||
is_workspace_checked = true;
|
||||
server.diagnose_workspace()?;
|
||||
}
|
||||
"shutdown" => {
|
||||
let id = value["id"].as_i64().unwrap();
|
||||
|
@ -135,11 +137,13 @@ fn main_loop(server: &mut TestingLS) -> Result<(), LSError> {
|
|||
_ => {
|
||||
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#responseMessage
|
||||
let id = value["id"].as_i64();
|
||||
send_error(
|
||||
id,
|
||||
-32601, // Method not found
|
||||
format!("method not found: {}", method),
|
||||
)?;
|
||||
if id.is_some() {
|
||||
send_error(
|
||||
id,
|
||||
-32601, // Method not found
|
||||
format!("method not found: {}", method),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue