Skip to content

Commit 2754a86

Browse files
committed
🥅 detailed error message
1 parent ad2f81b commit 2754a86

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/commands/install/make.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ static PROGRESS_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
1515

1616
#[derive(Error, Debug)]
1717
pub enum Error {
18-
#[error("Can't execute the command because {0}")]
19-
FailedExecute(#[from] std::io::Error),
18+
#[error("Can't execute `{command}` because {source}")]
19+
FailedExecute {
20+
command: String,
21+
#[source]
22+
source: std::io::Error,
23+
},
2024

2125
#[error(
2226
"build error\n=== Please follow the messages below to resolve dependencies, etc. ===\n\n{0}"
@@ -35,7 +39,7 @@ pub trait Command {
3539
&self,
3640
current_dir: impl AsRef<Path>,
3741
handle_wait: impl Fn(),
38-
) -> Result<std::process::Output, std::io::Error> {
42+
) -> Result<std::process::Output, Error> {
3943
let command = self.command();
4044
let args = self.args();
4145
let current_dir = current_dir.as_ref().to_path_buf();
@@ -51,7 +55,10 @@ pub trait Command {
5155
});
5256
loop {
5357
if let Ok(output) = rx.try_recv() {
54-
break output;
58+
break output.map_err(|source| Error::FailedExecute {
59+
command: self.command_line(),
60+
source,
61+
});
5562
}
5663
handle_wait();
5764
thread::sleep(Duration::from_millis(50));
@@ -82,10 +89,10 @@ impl Command for Configure<'_> {
8289
"./configure"
8390
}
8491
fn args(&self) -> Vec<String> {
85-
self.opts
92+
[format!("--prefix={}", self.prefix.display()).as_str()]
8693
.iter()
94+
.chain(self.opts.iter())
8795
.map(|&s| s.to_owned())
88-
.chain([format!("--prefix={}", self.prefix.display())])
8996
.collect_vec()
9097
}
9198
fn order(&self) -> usize {

0 commit comments

Comments
 (0)