mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Avoid failing on incorrect settings response
This commit is contained in:
parent
fbef0127ba
commit
2a19459ee9
1 changed files with 13 additions and 5 deletions
|
@ -414,18 +414,23 @@ fn loop_turn(
|
|||
log::error!("unexpected response: {:?}", resp)
|
||||
}
|
||||
|
||||
if Some(resp.id) == loop_state.configuration_request_id {
|
||||
if Some(&resp.id) == loop_state.configuration_request_id.as_ref() {
|
||||
loop_state.configuration_request_id = None;
|
||||
log::debug!("config update response: '{:?}", resp);
|
||||
let Response { error, result, .. } = resp;
|
||||
match (error, result) {
|
||||
|
||||
match (
|
||||
error,
|
||||
result.map(|result| serde_json::from_value::<Vec<ServerConfig>>(result)),
|
||||
) {
|
||||
(Some(err), _) => {
|
||||
log::error!("failed to fetch the server settings: {:?}", err)
|
||||
}
|
||||
(None, Some(result)) => {
|
||||
let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)?
|
||||
(None, Some(Ok(new_config))) => {
|
||||
let new_config = new_config
|
||||
.first()
|
||||
.expect(
|
||||
"The client is expected to always send a non-empty config data",
|
||||
"the client is expected to always send a non-empty config data",
|
||||
)
|
||||
.to_owned();
|
||||
world_state.update_configuration(
|
||||
|
@ -434,6 +439,9 @@ fn loop_turn(
|
|||
get_feature_flags(&new_config, connection),
|
||||
);
|
||||
}
|
||||
(None, Some(Err(e))) => {
|
||||
log::error!("failed to parse client config response: {}", e)
|
||||
}
|
||||
(None, None) => {
|
||||
log::error!("received empty server settings response from the client")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue