Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit aac5ec0

Browse files
committed
fix(error): Report context for spawmn failures
1 parent 189026b commit aac5ec0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/assert.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use environment::Environment;
2+
use error_chain::ChainedError;
23
use errors::*;
34
use output::{OutputAssertion, OutputKind};
45
use std::default;
@@ -308,7 +309,9 @@ impl Assert {
308309
None => command,
309310
};
310311

311-
let mut spawned = command.spawn()?;
312+
let mut spawned = command
313+
.spawn()
314+
.chain_err(|| ErrorKind::SpawnFailed(self.cmd.clone()))?;
312315

313316
if let Some(ref contents) = self.stdin_contents {
314317
spawned
@@ -365,7 +368,7 @@ impl Assert {
365368
/// ```
366369
pub fn unwrap(self) {
367370
if let Err(err) = self.execute() {
368-
panic!("{}", err);
371+
panic!("{}", err.display_chain());
369372
}
370373
}
371374
}

src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ error_chain! {
66
Fmt(::std::fmt::Error);
77
}
88
errors {
9+
SpawnFailed(cmd: Vec<String>) {
10+
description("Spawn failed")
11+
display(
12+
"{}: (command `{}` failed to run)",
13+
ERROR_PREFIX,
14+
cmd.join(" "),
15+
)
16+
}
917
StatusMismatch(cmd: Vec<String>, expected: bool, out: String, err: String) {
1018
description("Wrong status")
1119
display(

0 commit comments

Comments
 (0)