feat(cli): include stderr in command error

This commit is contained in:
Lucas Nogueira
2026-02-28 10:04:00 -03:00
parent f20256bca5
commit a75e3b1bcd
3 changed files with 15 additions and 7 deletions

View File

@@ -0,0 +1,7 @@
---
"@tauri-apps/cli": patch:enhance
"tauri-cli": patch:enhance
"tauri-bundler": patch:enhance
---
When a captured command fails, include its stderr in the error message.

View File

@@ -102,9 +102,10 @@ impl CommandExt for Command {
if output.status.success() {
Ok(output)
} else {
Err(crate::Error::GenericError(format!(
"failed to run {program}"
)))
Err(crate::Error::CommandFailed {
command: program,
error: std::io::Error::other(String::from_utf8_lossy(&output.stderr).to_string()),
})
}
}
}

View File

@@ -411,10 +411,10 @@ impl CommandExt for Command {
if output.status.success() {
Ok(output)
} else {
crate::error::bail!(
"failed to run command `{cmdline}`: command exited with status code {}",
output.status.code().unwrap_or(-1)
);
Err(crate::error::Error::CommandFailed {
command: cmdline,
error: std::io::Error::other(String::from_utf8_lossy(&output.stderr).to_string()),
})
}
}
}