Skip to content

Commit

Permalink
improve error reporting for spawning error
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-guo committed Oct 18, 2023
1 parent 2fcad41 commit 8568602
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,7 @@ impl GroupCmds {
pub fn spawn(mut self, with_output: bool) -> Result<CmdChildren> {
assert_eq!(self.group_cmds.len(), 1);
let mut cmds = self.group_cmds.pop().unwrap();
let ret = cmds.spawn(&mut self.current_dir, with_output);
// spawning error contains no command information, attach it here
if let Err(ref e) = ret {
if !cmds.ignore_error {
return Err(new_cmd_io_error(e, &cmds.full_cmds));
}
}
ret
cmds.spawn(&mut self.current_dir, with_output)
}

pub fn spawn_with_output(self) -> Result<FunChildren> {
Expand Down Expand Up @@ -188,9 +181,10 @@ impl Cmds {
}

fn spawn(&mut self, current_dir: &mut PathBuf, with_output: bool) -> Result<CmdChildren> {
let full_cmds = &self.full_cmds;
if debug_enabled() {
let _ = try_init_default_logger();
debug!("Running {} ...", self.full_cmds);
debug!("Running {full_cmds} ...");
}

// spawning all the sub-processes
Expand All @@ -207,7 +201,9 @@ impl Cmds {
} else {
cmd.setup_redirects(&mut prev_pipe_in, None, with_output)?;
}
let child = cmd.spawn(current_dir, with_output)?;
let child = cmd
.spawn(current_dir, with_output)
.map_err(|e| new_cmd_io_error(&e, full_cmds))?;
children.push(child);
}

Expand Down

0 comments on commit 8568602

Please sign in to comment.