diff options
author | sigmaSd <bedisnbiba@gmail.com> | 2023-07-19 00:24:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-19 01:24:30 +0200 |
commit | cfb9478a43379d7c1dcd5556e7f99a6b0861f486 (patch) | |
tree | 71ebcf0d1e8e08f449a3417dbcc73d56b3a07630 /runtime/ops/process.rs | |
parent | bab0294db674c64c18243a877e9dff5f9a91c923 (diff) |
fix(runtime): print process name in case of spawn error (#19855)
Fix https://github.com/denoland/deno/issues/19400
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'runtime/ops/process.rs')
-rw-r--r-- | runtime/ops/process.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 14d773af0..076c13765 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -2,6 +2,7 @@ use super::check_unstable; use crate::permissions::PermissionsContainer; +use deno_core::anyhow::Context; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::op; @@ -285,7 +286,12 @@ fn spawn_child( // We want to kill child when it's closed command.kill_on_drop(true); - let mut child = command.spawn()?; + let mut child = command.spawn().with_context(|| { + format!( + "Failed to spawn: {}", + command.as_std().get_program().to_string_lossy() + ) + })?; let pid = child.id().expect("Process ID should be set."); let stdin_rid = child @@ -352,8 +358,13 @@ fn op_spawn_sync( ) -> Result<SpawnOutput, AnyError> { let stdout = matches!(args.stdio.stdout, Stdio::Piped); let stderr = matches!(args.stdio.stderr, Stdio::Piped); - let output = - create_command(state, args, "Deno.Command().outputSync()")?.output()?; + let mut command = create_command(state, args, "Deno.Command().outputSync()")?; + let output = command.output().with_context(|| { + format!( + "Failed to spawn: {}", + command.get_program().to_string_lossy() + ) + })?; Ok(SpawnOutput { status: output.status.try_into()?, |