From 0149725d772d6e840c15eed08f76646fd4ecbc74 Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 31 Mar 2021 22:13:36 +0200 Subject: [PATCH] Log error instead of panicking when child fails to start --- src/main.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 53603152..f988a63d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -639,16 +639,20 @@ impl Future for Main { progress = true; if let Some(ref program) = self.player_event_program { if let Some(child) = run_program_on_events(event, program) { - let child = child - .expect("program failed to start") - .map(|status| { - if !status.success() { - error!("child exited with status {:?}", status.code()); - } - }) - .map_err(|e| error!("failed to wait on child process: {}", e)); + if child.is_ok() { + let child = child + .unwrap() + .map(|status| { + if !status.success() { + error!("child exited with status {:?}", status.code()); + } + }) + .map_err(|e| error!("failed to wait on child process: {}", e)); - self.handle.spawn(child); + self.handle.spawn(child); + } else { + error!("{:?} failed to start", program); + } } } }