Skip to content

Commit 7bd2d57

Browse files
author
Jigglyclaw Local Worker
committed
fix(exec): include stderr in ExecError display
1 parent 7954d02 commit 7bd2d57

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/cortex-engine/src/unified_exec/errors.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ impl fmt::Display for ExecError {
142142
write!(f, " (exit code: {code})")?;
143143
}
144144

145+
if let Some(ref stderr) = self.stderr {
146+
if !stderr.is_empty() {
147+
write!(f, " (stderr: {stderr})")?;
148+
}
149+
}
150+
145151
Ok(())
146152
}
147153
}
@@ -232,6 +238,22 @@ mod tests {
232238
assert!(display.contains("timed out"));
233239
}
234240

241+
#[test]
242+
fn test_error_display_includes_stderr() {
243+
let err = ExecError::exit("bash -c 'exit 1'", 1, Some("error-detail".to_string()));
244+
let display = format!("{}", err);
245+
246+
assert!(display.contains("stderr: error-detail"));
247+
}
248+
249+
#[test]
250+
fn test_error_display_omits_empty_stderr() {
251+
let err = ExecError::exit("bash -c 'exit 1'", 1, Some(String::new()));
252+
let display = format!("{}", err);
253+
254+
assert!(!display.contains("stderr:"));
255+
}
256+
235257
#[test]
236258
fn test_retriable() {
237259
assert!(ExecError::timeout("cmd", 10).is_retriable());

0 commit comments

Comments
 (0)