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

Commit 41f4e10

Browse files
committed
fix(error): Report context for spawmn failures
1 parent a01f933 commit 41f4e10

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;
@@ -332,7 +333,9 @@ impl Assert {
332333
None => command,
333334
};
334335

335-
let mut spawned = command.spawn()?;
336+
let mut spawned = command
337+
.spawn()
338+
.chain_err(|| ErrorKind::SpawnFailed(self.cmd.clone()))?;
336339

337340
if let Some(ref contents) = self.stdin_contents {
338341
spawned
@@ -389,7 +392,7 @@ impl Assert {
389392
/// ```
390393
pub fn unwrap(self) {
391394
if let Err(err) = self.execute() {
392-
panic!("{}", err);
395+
panic!("{}", err.display_chain());
393396
}
394397
}
395398
}

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)