Fix: cargo running desktop shouldn't panic
This commit is contained in:
1 file changed
+10
-5
@@ -33,8 +33,10 @@ pub fn connect(mut callback: impl FnMut(HotReloadMsg) + Send + 'static) {
|
|||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let path = PathBuf::from("./").join("target").join("dioxusin");
|
let path = PathBuf::from("./").join("target").join("dioxusin");
|
||||||
|
|
||||||
let socket =
|
// There might be a socket since the we're not running under the hot reloading server
|
||||||
LocalSocketStream::connect(path).expect("Could not connect to hot reloading server.");
|
let Ok(socket) = LocalSocketStream::connect(path) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
let mut buf_reader = BufReader::new(socket);
|
let mut buf_reader = BufReader::new(socket);
|
||||||
|
|
||||||
@@ -47,9 +49,12 @@ pub fn connect(mut callback: impl FnMut(HotReloadMsg) + Send + 'static) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let template = serde_json::from_str(Box::leak(buf.into_boxed_str())).expect(
|
let Ok(template) = serde_json::from_str(Box::leak(buf.into_boxed_str())) else {
|
||||||
"Could not parse hot reloading message - make sure your client is up to date",
|
eprintln!(
|
||||||
);
|
"Could not parse hot reloading message - make sure your client is up to date"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
callback(template);
|
callback(template);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user