fn git_inherit(path: &Path, verbose: bool, str: String) -> CargoResult<()> {
git(path, verbose, str.as_slice()).exec().map_err(|err|
- human_error(format!("Couldn't execute `git {}`: {}", str, err), None::<&str>, err))
+ human_error(format!("Executing `git {}` failed: {}", str, err), None::<&str>, err))
}
fn git_output(path: &Path, verbose: bool, str: String) -> CargoResult<String> {
let output = try!(git(path, verbose, str.as_slice()).exec_with_output().map_err(|err|
- human_error(format!("Couldn't execute `git {}`", str), None::<&str>, err)));
+ human_error(format!("Executing `git {}` failed", str), None::<&str>, err)));
Ok(to_str(output.output.as_slice()).as_slice().trim_right().to_str())
}
}
}
-#[deriving(Show,Clone)]
+#[deriving(Eq,Clone)]
pub struct CargoError {
pub kind: CargoErrorKind,
desc: CargoErrorDescription,
cause: Option<Box<CargoError>>
}
-#[deriving(Show,Clone)]
+impl Show for CargoError {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ match self.desc {
+ StaticDescription(string) => write!(f, "{}", string),
+ BoxedDescription(ref string) => write!(f, "{}", string)
+ }
+ }
+}
+
+#[deriving(Eq,Show,Clone)]
enum CargoErrorDescription {
StaticDescription(&'static str),
BoxedDescription(String)
}
}
+#[deriving(Eq)]
pub enum CargoErrorKind {
HumanReadableError,
InternalError,