mirror of https://github.com/rust-lang/cargo
Improve errors slightly
This commit is contained in:
parent
5732f5a4bf
commit
30cc28333d
|
@ -317,12 +317,12 @@ fn git(path: &Path, verbose: bool, str: &str) -> ProcessBuilder {
|
|||
|
||||
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())
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ pub fn toml_error(desc: &'static str, error: toml::Error) -> CargoError {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Show,Clone)]
|
||||
#[deriving(Eq,Clone)]
|
||||
pub struct CargoError {
|
||||
pub kind: CargoErrorKind,
|
||||
desc: CargoErrorDescription,
|
||||
|
@ -77,7 +77,16 @@ pub struct CargoError {
|
|||
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)
|
||||
|
@ -118,6 +127,7 @@ impl CargoError {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
pub enum CargoErrorKind {
|
||||
HumanReadableError,
|
||||
InternalError,
|
||||
|
|
Loading…
Reference in New Issue