Browse Source

refactor!: change `Webview::navigate` to return result (#10134)

closes #9935
Amr Bashir 1 năm trước cách đây
mục cha
commit
3afe828940

+ 5 - 0
.changes/webview-navigate-result.md

@@ -0,0 +1,5 @@
+---
+"tauri": "patch:breaking"
+---
+
+Changed `WebviewWindow::navigate` and `Webview::navigate` method signature to return a `Result`

+ 2 - 2
core/tauri/src/webview/mod.rs

@@ -1084,8 +1084,8 @@ fn main() {
   }
 
   /// Navigates the webview to the defined url.
-  pub fn navigate(&mut self, url: Url) {
-    self.webview.dispatcher.navigate(url).unwrap();
+  pub fn navigate(&mut self, url: Url) -> crate::Result<()> {
+    self.webview.dispatcher.navigate(url).map_err(Into::into)
   }
 
   fn is_local_url(&self, current_url: &Url) -> bool {

+ 2 - 2
core/tauri/src/webview/webview_window.rs

@@ -1665,8 +1665,8 @@ impl<R: Runtime> WebviewWindow<R> {
   }
 
   /// Navigates the webview to the defined url.
-  pub fn navigate(&mut self, url: Url) {
-    self.webview.navigate(url);
+  pub fn navigate(&mut self, url: Url) -> crate::Result<()> {
+    self.webview.navigate(url)
   }
 
   /// Handles this window receiving an [`crate::webview::InvokeRequest`].