Better error model

This commit is contained in:
Roey Darwish Dror
2018-12-11 16:43:26 +02:00
parent f23b6435bf
commit 370310948b
16 changed files with 216 additions and 124 deletions

View File

@@ -1,5 +1,4 @@
use failure::Error;
use failure_derive::Fail;
use super::error::{Error, ErrorKind};
use log::{debug, error};
use std::ffi::OsStr;
use std::fmt::Debug;
@@ -7,10 +6,6 @@ use std::path::{Path, PathBuf};
use std::process::{ExitStatus, Output};
use which as which_mod;
#[derive(Fail, Debug)]
#[fail(display = "Process failed")]
pub struct ProcessFailed;
pub trait Check {
fn check(self) -> Result<(), Error>;
}
@@ -20,7 +15,7 @@ impl Check for ExitStatus {
if self.success() {
Ok(())
} else {
Err(Error::from(ProcessFailed {}))
Err(ErrorKind::ProcessFailed(self))?
}
}
}