fix: exec errors show first stderr line instead of 'exit 1'
This commit is contained in:
parent
996f74b24f
commit
5fd01a423d
1 changed files with 14 additions and 8 deletions
|
|
@ -374,18 +374,24 @@ async fn handle_message(
|
||||||
let mut sh = shell.lock().await;
|
let mut sh = shell.lock().await;
|
||||||
match sh.run(&command, timeout_ms).await {
|
match sh.run(&command, timeout_ms).await {
|
||||||
Ok((stdout, stderr, exit_code)) => {
|
Ok((stdout, stderr, exit_code)) => {
|
||||||
let first_line = stdout.trim().lines().next().unwrap_or("").to_string();
|
|
||||||
let result = if exit_code != 0 {
|
let result = if exit_code != 0 {
|
||||||
if first_line.is_empty() {
|
// For errors: use first non-empty stderr line (actual error message),
|
||||||
format!("exit {exit_code}")
|
// ignoring PowerShell boilerplate like "+ CategoryInfo", "In Zeile:", etc.
|
||||||
} else {
|
let err_line = stderr.lines()
|
||||||
format!("{first_line} · exit {exit_code}")
|
.map(|l| l.trim())
|
||||||
}
|
.find(|l| !l.is_empty()
|
||||||
|
&& !l.starts_with("In Zeile:")
|
||||||
|
&& !l.starts_with("+ ")
|
||||||
|
&& !l.starts_with("CategoryInfo")
|
||||||
|
&& !l.starts_with("FullyQualifiedErrorId"))
|
||||||
|
.unwrap_or("error")
|
||||||
|
.to_string();
|
||||||
|
err_line
|
||||||
} else {
|
} else {
|
||||||
first_line // success: just the output, no "exit 0"
|
// Success: first stdout line, no exit code
|
||||||
|
stdout.trim().lines().next().unwrap_or("").to_string()
|
||||||
};
|
};
|
||||||
display::cmd_done("⚡", "execute", &payload, exit_code == 0, &result);
|
display::cmd_done("⚡", "execute", &payload, exit_code == 0, &result);
|
||||||
let _ = stderr;
|
|
||||||
ClientMessage::ExecResponse { request_id, stdout, stderr, exit_code }
|
ClientMessage::ExecResponse { request_id, stdout, stderr, exit_code }
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue