diff --git a/.changes/webview-navigate-result.md b/.changes/webview-navigate-result.md new file mode 100644 index 000000000..bf7b1784f --- /dev/null +++ b/.changes/webview-navigate-result.md @@ -0,0 +1,5 @@ +--- +"tauri": "patch:breaking" +--- + +Changed `WebviewWindow::navigate` and `Webview::navigate` method signature to return a `Result` diff --git a/core/tauri/src/webview/mod.rs b/core/tauri/src/webview/mod.rs index 70adee590..12210d460 100644 --- a/core/tauri/src/webview/mod.rs +++ b/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 { diff --git a/core/tauri/src/webview/webview_window.rs b/core/tauri/src/webview/webview_window.rs index 6e718b1c8..82cc09b4b 100644 --- a/core/tauri/src/webview/webview_window.rs +++ b/core/tauri/src/webview/webview_window.rs @@ -1665,8 +1665,8 @@ impl WebviewWindow { } /// 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`].