From 06c63e8afe6296247d6ac45fd73ac22bae4c2898 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 26 Sep 2024 02:47:43 +0300 Subject: [PATCH] update connection error handler --- src/browser/main/tab/page/mod.rs | 48 ++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/browser/main/tab/page/mod.rs b/src/browser/main/tab/page/mod.rs index 7a52dcd2..d94a16cd 100644 --- a/src/browser/main/tab/page/mod.rs +++ b/src/browser/main/tab/page/mod.rs @@ -186,44 +186,70 @@ impl Page { ); } Err(e) => { - eprintln!( - "Failed to read buffer: {e}" - ) + meta.borrow_mut().title = GString::from("Oops"); + meta.borrow_mut().description = GString::from(format!("Failed to read buffer data: {e}")); + meta.borrow_mut().progress_fraction = 1.0; + + let _ = widget.activate_action( + "win.update", + None, + ); } } // Close connection if let Err(e) = connection.close(Some(&cancellable)) { - eprintln!("Error closing connection: {:?}", e); + panic!("Error closing connection: {:?}", e); } } Err(e) => { - eprintln!( - "Failed to read response: {:?}", - e + // Update + meta.borrow_mut().title = GString::from("Oops"); + meta.borrow_mut().description = GString::from(format!("Failed to read response: {:?}", e)); + meta.borrow_mut().progress_fraction = 1.0; + + let _ = widget.activate_action( + "win.update", + None, ); // Close connection if let Err(e) = connection.close(Some(&cancellable)) { - eprintln!("Error closing connection: {:?}", e); + panic!("Error closing response connection: {:?}", e); } } }, ); } Err(e) => { - eprintln!("Failed to write request: {:?}", e); + // Update + meta.borrow_mut().title = GString::from("Oops"); + meta.borrow_mut().description = GString::from(format!("Failed to read request: {:?}", e)); + meta.borrow_mut().progress_fraction = 1.0; + + let _ = widget.activate_action( + "win.update", + None, + ); // Close connection if let Err(e) = connection.close(Some(&cancellable)) { - eprintln!("Error closing connection: {:?}", e); + panic!("Error closing request connection: {:?}", e); } } }, ); } Err(e) => { - eprintln!("Failed to connect: {e}"); // @TODO + // Update + meta.borrow_mut().title = GString::from("Oops"); + meta.borrow_mut().description = GString::from(format!("Failed to connect: {:?}", e)); + meta.borrow_mut().progress_fraction = 1.0; + + let _ = widget.activate_action( + "win.update", + None, + ); } }, );