Summary
When exec/execFile run a command that exits non-zero, the (err, stdout, stderr) callback fires with a bare Error("Command failed"). Node attaches diagnostic properties that callers routinely read.
Verified against node --experimental-strip-types:
cp.exec("exit 3", (e) => { /* Object.keys(e) → */ "code,killed,signal,cmd" });
// e.code === 3 e.killed === false e.signal === null e.cmd === "exit 3"
Today (perry 0.5.1029) e.code/e.killed/e.signal/e.cmd are all undefined.
What to do
- On non-zero exit, populate the callback
Error with code (numeric exit code, or the signal name when killed by signal), signal (string | null), killed (boolean), and cmd (the command string; for execFile, file + args).
- On spawn failure (e.g. ENOENT), Node sets
code to the errno string ("ENOENT") plus errno/syscall/path — worth matching too.
The error is built in js_child_process_exec / js_child_process_exec_file in crates/perry-runtime/src/child_process.rs (currently js_error_new_with_message("Command failed")).
Parent: #1780. perry 0.5.1029.
Summary
When
exec/execFilerun a command that exits non-zero, the(err, stdout, stderr)callback fires with a bareError("Command failed"). Node attaches diagnostic properties that callers routinely read.Verified against
node --experimental-strip-types:Today (perry 0.5.1029)
e.code/e.killed/e.signal/e.cmdare allundefined.What to do
Errorwithcode(numeric exit code, or the signal name when killed by signal),signal(string |null),killed(boolean), andcmd(the command string; forexecFile,file+ args).codeto the errno string ("ENOENT") pluserrno/syscall/path— worth matching too.The error is built in
js_child_process_exec/js_child_process_exec_fileincrates/perry-runtime/src/child_process.rs(currentlyjs_error_new_with_message("Command failed")).Parent: #1780. perry 0.5.1029.