diff --git a/.changes/deep-link-linux-errors.md b/.changes/deep-link-linux-errors.md new file mode 100644 index 0000000000..53cc30b07d --- /dev/null +++ b/.changes/deep-link-linux-errors.md @@ -0,0 +1,6 @@ +--- +deep-link: patch +deep-link-js: patch +--- + +On Linux, improved error messages when OS commands fail. diff --git a/plugins/deep-link/src/error.rs b/plugins/deep-link/src/error.rs index 88c71e8a53..07c8d72cd1 100644 --- a/plugins/deep-link/src/error.rs +++ b/plugins/deep-link/src/error.rs @@ -23,6 +23,9 @@ pub enum Error { #[cfg(target_os = "linux")] #[error(transparent)] ParseIni(#[from] ini::ParseError), + #[cfg(target_os = "linux")] + #[error("Failed to run OS command `{0}`: {1}")] + Execute(&'static str, #[source] std::io::Error), #[cfg(mobile)] #[error(transparent)] PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 1cd13b580a..04c7ce86d3 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -254,6 +254,7 @@ mod imp { /// /// ## Platform-specific: /// + /// - **Linux**: Needs the `xdg-mime` and `update-desktop-database` commands available on the system. /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). pub fn register>(&self, _protocol: S) -> crate::Result<()> { #[cfg(windows)] @@ -332,11 +333,13 @@ mod imp { Command::new("update-desktop-database") .arg(target) - .status()?; + .status() + .map_err(|error| crate::Error::Execute("update-desktop-database", error))?; Command::new("xdg-mime") .args(["default", &file_name, mime_type.as_str()]) - .status()?; + .status() + .map_err(|error| crate::Error::Execute("xdg-mime", error))?; Ok(()) } @@ -405,6 +408,7 @@ mod imp { /// /// ## Platform-specific: /// + /// - **Linux**: Needs the `xdg-mime` command available on the system. /// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`). pub fn is_registered>(&self, _protocol: S) -> crate::Result { #[cfg(windows)] @@ -439,7 +443,8 @@ mod imp { "default", &format!("x-scheme-handler/{}", _protocol.as_ref()), ]) - .output()?; + .output() + .map_err(|error| crate::Error::Execute("xdg-mime", error))?; Ok(String::from_utf8_lossy(&output.stdout).contains(&file_name)) }