fix(deep-link): Add command name to linux errors (#2928)

This commit is contained in:
Fabian-Lars
2025-08-21 13:56:09 +02:00
committed by GitHub
parent 8abb31ee59
commit 21d721a0c2
3 changed files with 17 additions and 3 deletions
+6
View File
@@ -0,0 +1,6 @@
---
deep-link: patch
deep-link-js: patch
---
On Linux, improved error messages when OS commands fail.
+3
View File
@@ -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),
+8 -3
View File
@@ -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<S: AsRef<str>>(&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<S: AsRef<str>>(&self, _protocol: S) -> crate::Result<bool> {
#[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))
}