mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
fix: don't panic if the client sends invalid request
This commit is contained in:
parent
ac2520128d
commit
33199b7e43
2 changed files with 9 additions and 3 deletions
|
@ -10,7 +10,7 @@ use crate::{
|
|||
from_json,
|
||||
global_state::GlobalStateSnapshot,
|
||||
line_index::{LineIndex, OffsetEncoding},
|
||||
lsp_ext, Result,
|
||||
lsp_ext, LspError, Result,
|
||||
};
|
||||
|
||||
pub(crate) fn abs_path(url: &lsp_types::Url) -> Result<AbsPathBuf> {
|
||||
|
@ -85,7 +85,10 @@ pub(crate) fn annotation(
|
|||
snap: &GlobalStateSnapshot,
|
||||
code_lens: lsp_types::CodeLens,
|
||||
) -> Result<Annotation> {
|
||||
let data = code_lens.data.unwrap();
|
||||
let data = code_lens.data.ok_or_else(|| LspError {
|
||||
code: lsp_server::ErrorCode::InvalidParams as i32,
|
||||
message: "code lens without data".to_string(),
|
||||
});
|
||||
let resolve = from_json::<lsp_ext::CodeLensResolveData>("CodeLensResolveData", data)?;
|
||||
|
||||
match resolve {
|
||||
|
|
|
@ -1038,7 +1038,10 @@ pub(crate) fn handle_code_action_resolve(
|
|||
let _p = profile::span("handle_code_action_resolve");
|
||||
let params = match code_action.data.take() {
|
||||
Some(it) => it,
|
||||
None => Err("can't resolve code action without data")?,
|
||||
None => Err(LspError {
|
||||
code: lsp_server::ErrorCode::InvalidParams as i32,
|
||||
message: format!("code action without data"),
|
||||
})?,
|
||||
};
|
||||
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.code_action_params.text_document.uri)?;
|
||||
|
|
Loading…
Reference in a new issue