mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +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)
|
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;
|
loop_state.configuration_request_id = None;
|
||||||
|
log::debug!("config update response: '{:?}", resp);
|
||||||
let Response { error, result, .. } = resp;
|
let Response { error, result, .. } = resp;
|
||||||
match (error, result) {
|
|
||||||
|
match (
|
||||||
|
error,
|
||||||
|
result.map(|result| serde_json::from_value::<Vec<ServerConfig>>(result)),
|
||||||
|
) {
|
||||||
(Some(err), _) => {
|
(Some(err), _) => {
|
||||||
log::error!("failed to fetch the server settings: {:?}", err)
|
log::error!("failed to fetch the server settings: {:?}", err)
|
||||||
}
|
}
|
||||||
(None, Some(result)) => {
|
(None, Some(Ok(new_config))) => {
|
||||||
let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)?
|
let new_config = new_config
|
||||||
.first()
|
.first()
|
||||||
.expect(
|
.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();
|
.to_owned();
|
||||||
world_state.update_configuration(
|
world_state.update_configuration(
|
||||||
|
@ -434,6 +439,9 @@ fn loop_turn(
|
||||||
get_feature_flags(&new_config, connection),
|
get_feature_flags(&new_config, connection),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
(None, Some(Err(e))) => {
|
||||||
|
log::error!("failed to parse client config response: {}", e)
|
||||||
|
}
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
log::error!("received empty server settings response from the client")
|
log::error!("received empty server settings response from the client")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue