Fix devtool crashs after clicking Enable connection prompt (#33305)

* Fix devtool crashs after clicking Enable connection prompt

Signed-off-by: Taym <haddadi.taym@gmail.com>

* Use early error return

Signed-off-by: Taym <haddadi.taym@gmail.com>

---------

Signed-off-by: Taym <haddadi.taym@gmail.com>
This commit is contained in:
Taym Haddadi 2024-09-07 22:58:16 +02:00 committed by GitHub
parent 567c3185f8
commit a43e296436
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
use std::collections::HashMap;
use std::net::TcpStream;
use log::warn;
use serde::Serialize;
use serde_json::{Map, Value};
use servo_config::pref_util::PrefValue;
@ -37,7 +38,10 @@ impl Actor for PreferenceActor {
stream: &mut TcpStream,
_id: StreamId,
) -> Result<ActorMessageStatus, ()> {
let mut key = msg.get("value").unwrap().as_str().unwrap();
let Some(mut key) = msg.get("value").and_then(|v| v.as_str()) else {
warn!("PreferenceActor: handle_message: value is not a string");
return Ok(ActorMessageStatus::Ignored);
};
// Mapping to translate a Firefox preference name onto the corresponding Servo preference name
let pref_name_mapping: HashMap<&str, &str> =