diff options
author | Kirill Bulatov <[email protected]> | 2020-03-24 19:43:22 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-30 11:39:14 +0100 |
commit | 2a19459ee91ce2ee002c6d5fa4a53bc446d11d60 (patch) | |
tree | 693abad2acabf89fdbd49e868c34e06be25785ba /crates | |
parent | fbef0127ba89e44796ca9594435fd01bbe77c36d (diff) |
Avoid failing on incorrect settings response
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 0ab5b9ef5..79ea90cc9 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -414,18 +414,23 @@ fn loop_turn( | |||
414 | log::error!("unexpected response: {:?}", resp) | 414 | log::error!("unexpected response: {:?}", resp) |
415 | } | 415 | } |
416 | 416 | ||
417 | if Some(resp.id) == loop_state.configuration_request_id { | 417 | if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { |
418 | loop_state.configuration_request_id = None; | 418 | loop_state.configuration_request_id = None; |
419 | log::debug!("config update response: '{:?}", resp); | ||
419 | let Response { error, result, .. } = resp; | 420 | let Response { error, result, .. } = resp; |
420 | match (error, result) { | 421 | |
422 | match ( | ||
423 | error, | ||
424 | result.map(|result| serde_json::from_value::<Vec<ServerConfig>>(result)), | ||
425 | ) { | ||
421 | (Some(err), _) => { | 426 | (Some(err), _) => { |
422 | log::error!("failed to fetch the server settings: {:?}", err) | 427 | log::error!("failed to fetch the server settings: {:?}", err) |
423 | } | 428 | } |
424 | (None, Some(result)) => { | 429 | (None, Some(Ok(new_config))) => { |
425 | let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)? | 430 | let new_config = new_config |
426 | .first() | 431 | .first() |
427 | .expect( | 432 | .expect( |
428 | "The client is expected to always send a non-empty config data", | 433 | "the client is expected to always send a non-empty config data", |
429 | ) | 434 | ) |
430 | .to_owned(); | 435 | .to_owned(); |
431 | world_state.update_configuration( | 436 | world_state.update_configuration( |
@@ -434,6 +439,9 @@ fn loop_turn( | |||
434 | get_feature_flags(&new_config, connection), | 439 | get_feature_flags(&new_config, connection), |
435 | ); | 440 | ); |
436 | } | 441 | } |
442 | (None, Some(Err(e))) => { | ||
443 | log::error!("failed to parse client config response: {}", e) | ||
444 | } | ||
437 | (None, None) => { | 445 | (None, None) => { |
438 | log::error!("received empty server settings response from the client") | 446 | log::error!("received empty server settings response from the client") |
439 | } | 447 | } |