mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
log parse errors
This commit is contained in:
parent
f132a08f7d
commit
586983291a
3 changed files with 19 additions and 11 deletions
|
@ -81,13 +81,16 @@ impl DesktopController {
|
|||
impl ErrorHandler for DesktopErrorHandler {
|
||||
fn handle_error(&self, err: Error) {
|
||||
if let Some(conn) = &mut *self.latest_connection.lock().unwrap() {
|
||||
if let Error::RecompileRequiredError(reason) = err {
|
||||
conn.get_mut()
|
||||
.write_all(
|
||||
(serde_json::to_string(&reason).unwrap() + "\n")
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
match err {
|
||||
Error::RecompileRequiredError(reason) => {
|
||||
conn.get_mut()
|
||||
.write_all(
|
||||
(serde_json::to_string(&reason).unwrap() + "\n")
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
Error::ParseError(err) => log::warn!("{}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ features = [
|
|||
[features]
|
||||
default = ["panic_hook"]
|
||||
panic_hook = ["console_error_panic_hook"]
|
||||
hot_reload = ["dioxus-rsx-interpreter", "web-sys/WebSocket", "web-sys/Location", "web-sys/MessageEvent", "serde_json"]
|
||||
hot_reload = ["dioxus-rsx-interpreter", "web-sys/WebSocket", "web-sys/Location", "web-sys/MessageEvent", "web-sys/console", "serde_json"]
|
||||
|
||||
[dev-dependencies]
|
||||
dioxus-core-macro = { path = "../core-macro" }
|
||||
|
|
|
@ -275,9 +275,14 @@ pub async fn run_with_props<T: 'static + Send>(root: Component<T>, root_props: T
|
|||
// forward stream to the websocket
|
||||
dom.base_scope().spawn_forever(async move {
|
||||
while let Some(err) = error_channel_receiver.next().await {
|
||||
if let Error::RecompileRequiredError(err) = err {
|
||||
ws.send_with_str(serde_json::to_string(&err).unwrap().as_str())
|
||||
.unwrap();
|
||||
match err {
|
||||
Error::RecompileRequiredError(err) => {
|
||||
ws.send_with_str(serde_json::to_string(&err).unwrap().as_str())
|
||||
.unwrap();
|
||||
}
|
||||
Error::ParseError(err) => {
|
||||
web_sys::console::warn_1(&wasm_bindgen::JsValue::from_str(&err.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue