Improve errors slightly
authorYehuda Katz <wycats@gmail.com>
Fri, 30 May 2014 01:11:27 +0000 (18:11 -0700)
committerYehuda Katz <wycats@gmail.com>
Fri, 30 May 2014 01:11:27 +0000 (18:11 -0700)
src/cargo/sources/git.rs
src/cargo/util/result.rs

index 740b934d1a8f9b74d1219cc21c314238d21a2dba..f2bc69fdce789e32b74d6268eea925d82d502d83 100644 (file)
@@ -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())
 }
index 8ce1b72fe6ed25152a352fe242f0d541572c30cc..26b235b88945787228df4e4dd777469aa4a1b4be 100644 (file)
@@ -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,