radicle/cob: Include command name on spawn fail

To improve the ability to work out what went wrong, should an external
cob helper not be found, report the command name if the spawn fails.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.dev>
This commit is contained in:
Daniel Silverstone 2026-06-17 22:04:52 +01:00 committed by Lorenz Leutgeb
parent 88bf2a9648
commit 07f748475b
1 changed files with 8 additions and 2 deletions

View File

@ -114,6 +114,8 @@ pub enum Error {
Op(#[from] OpEncodingError), Op(#[from] OpEncodingError),
#[error("serde_json: {0}")] #[error("serde_json: {0}")]
Serde(#[from] JsonError), Serde(#[from] JsonError),
#[error("failed to spawn program '{program}': {source}")]
Spawn { program: String, source: IoError },
#[error("io: {0}")] #[error("io: {0}")]
Io(#[from] IoError), Io(#[from] IoError),
} }
@ -158,10 +160,14 @@ impl External {
prefix + suffix prefix + suffix
}; };
let mut child = Command::new(command_name) let mut child = Command::new(&command_name)
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn()?; .spawn()
.map_err(|source| Error::Spawn {
program: command_name,
source,
})?;
let stdin = child.stdin.take().expect("handle preset"); let stdin = child.stdin.take().expect("handle preset");