Rename to
authorYehuda Katz <wycats@gmail.com>
Thu, 19 Jun 2014 17:43:46 +0000 (10:43 -0700)
committerYehuda Katz <wycats@gmail.com>
Thu, 19 Jun 2014 17:43:46 +0000 (10:43 -0700)
src/cargo/core/version_req.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_rustc.rs
src/cargo/sources/path.rs
src/cargo/util/config.rs
src/cargo/util/errors.rs
src/cargo/util/mod.rs
src/cargo/util/toml.rs

index 065f26bbe6bd2d417e7e6d5a0bc19eabc465f6f2..0019a7fad08b2b5ca37f9aa0b9c6ef7869cd3e30 100644 (file)
@@ -1,7 +1,7 @@
 use std::fmt;
 use std::str::CharOffsets;
 use semver::Version;
-use util::{CargoResult, error};
+use util::{CargoResult, internal};
 
 #[deriving(PartialEq,Clone)]
 pub struct VersionReq {
@@ -49,7 +49,7 @@ impl VersionReq {
         }
 
         if lexer.is_error() {
-            return Err(error("invalid version requirement"));
+            return Err(internal("invalid version requirement"));
         }
 
         predicates.push(try!(builder.build()));
@@ -151,12 +151,12 @@ impl PredBuilder {
 
     fn set_sigil(&mut self, sigil: &str) -> CargoResult<()> {
         if self.op.is_some() {
-            return Err(error("op already set"));
+            return Err(internal("op already set"));
         }
 
         match Op::from_sigil(sigil) {
             Some(op) => self.op = Some(op),
-            _ => return Err(error("invalid sigil"))
+            _ => return Err(internal("invalid sigil"))
         }
 
         Ok(())
@@ -188,12 +188,12 @@ impl PredBuilder {
     fn build(&self) -> CargoResult<Predicate> {
         let op = match self.op {
             Some(x) => x,
-            None => return Err(error("op required"))
+            None => return Err(internal("op required"))
         };
 
         let major = match self.major {
             Some(x) => x,
-            None => return Err(error("major version required"))
+            None => return Err(internal("major version required"))
         };
 
         Ok(Predicate {
@@ -384,7 +384,7 @@ fn parse_version_part(s: &str) -> CargoResult<uint> {
         let n = (c as uint) - ('0' as uint);
 
         if n > 9 {
-            return Err(error("version components must be numeric"));
+            return Err(internal("version components must be numeric"));
         }
 
         ret *= 10;
index 20544a0bfacd48d04939d999d021640852ebe746..d2370b39f5f81d836c53147cc39464863f30a9ba 100644 (file)
@@ -20,7 +20,7 @@ use core::{Source,SourceId,PackageSet,resolver};
 use core::registry::PackageRegistry;
 use ops;
 use sources::{PathSource};
-use util::{CargoResult, Wrap, config, error, human};
+use util::{CargoResult, Wrap, config, internal, human};
 
 pub fn compile(manifest_path: &Path) -> CargoResult<()> {
     log!(4, "compile; manifest-path={}", manifest_path.display());
@@ -56,7 +56,7 @@ fn source_ids_from_config() -> CargoResult<Vec<SourceId>> {
     let config_paths = configs.find_equiv(&"paths").map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new());
 
     let paths: Vec<Path> = match config_paths.get_value() {
-        &config::String(_) => return Err(error("The path was configured as a String instead of a List")),
+        &config::String(_) => return Err(internal("The path was configured as a String instead of a List")),
         &config::List(ref list) => list.iter().map(|path| Path::new(path.as_slice())).collect()
     };
 
index 59b7f42f069b5115bb1be0eb6209b8182a94afd0..0f6cee71522b5df51c3ebf62805826059c7afe4e 100644 (file)
@@ -3,7 +3,7 @@ use std::io;
 use std::path::Path;
 use core::{Package,PackageSet,Target};
 use util;
-use util::{CargoResult, ProcessBuilder, error, human};
+use util::{CargoResult, ChainError, ProcessBuilder, internal, human};
 
 type Args = Vec<String>;
 
@@ -45,8 +45,7 @@ fn compile_pkg(pkg: &Package, dest: &Path, deps_dir: &Path, primary: bool) -> Ca
 }
 
 fn mk_target(target: &Path) -> CargoResult<()> {
-    io::fs::mkdir_recursive(target, io::UserRWX)
-      .map_err(|_| error("could not create target directory"))
+    io::fs::mkdir_recursive(target, io::UserRWX).chain_error(|| internal("could not create target directory"))
 }
 
 fn rustc(root: &Path, target: &Target, dest: &Path, deps: &Path, verbose: bool) -> CargoResult<()> {
@@ -98,6 +97,6 @@ fn build_deps_args(dst: &mut Args, deps: &Path) {
 fn topsort(deps: &PackageSet) -> CargoResult<PackageSet> {
     match deps.sort() {
         Some(deps) => Ok(deps),
-        None => return Err(error("circular dependency detected"))
+        None => return Err(internal("circular dependency detected"))
     }
 }
index d60a5fa06b0f7d561e31fdd87f8c8cd9dc83902c..b4e45bdc32ef037dbd29d084e93cf23c024c5f4e 100644 (file)
@@ -2,7 +2,7 @@ use std::fmt;
 use std::fmt::{Show,Formatter};
 use core::{Package,PackageId,Summary,SourceId,Source};
 use ops;
-use util::{CargoResult, error};
+use util::{CargoResult, internal};
 
 pub struct PathSource {
     id: SourceId,
@@ -40,12 +40,12 @@ impl PathSource {
         log!(5, "get_root_package; source={}", self);
 
         if !self.updated {
-            return Err(error("source has not been updated"))
+            return Err(internal("source has not been updated"))
         }
 
         match self.packages.as_slice().head() {
             Some(pkg) => Ok(pkg.clone()),
-            None => Err(error("no package found in source"))
+            None => Err(internal("no package found in source"))
         }
     }
 }
index 75609be159167997034fc41399cb19d108b43c8d..e647dd6a654ae361dc9c667722ca0ea5086c3bac 100644 (file)
@@ -2,7 +2,7 @@ use std::{io,fmt,os};
 use std::collections::HashMap;
 use serialize::{Encodable,Encoder};
 use toml;
-use util::{CargoResult, ChainError, Require, error, internal_error, human};
+use util::{CargoResult, ChainError, Require, internal, human};
 
 pub struct Config {
     home_path: Path
@@ -95,8 +95,8 @@ impl fmt::Show for ConfigValue {
 }
 
 pub fn get_config(pwd: Path, key: &str) -> CargoResult<ConfigValue> {
-    find_in_tree(&pwd, |file| extract_config(file, key))
-        .map_err(|_| internal_error("config key not found", format!("key={}", key)))
+    find_in_tree(&pwd, |file| extract_config(file, key)).map_err(|_|
+        internal(format!("config key not found; key={}", key)))
 }
 
 pub fn all_configs(pwd: Path) -> CargoResult<HashMap<String, ConfigValue>> {
@@ -115,7 +115,7 @@ fn find_in_tree<T>(pwd: &Path, walk: |io::fs::File| -> CargoResult<T>) -> CargoR
     loop {
         let possible = current.join(".cargo").join("config");
         if possible.exists() {
-            let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| error("could not open file")));
+            let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| internal("could not open file")));
             match walk(file) {
                 Ok(res) => return Ok(res),
                 _ => ()
@@ -125,7 +125,7 @@ fn find_in_tree<T>(pwd: &Path, walk: |io::fs::File| -> CargoResult<T>) -> CargoR
         if !current.pop() { break; }
     }
 
-    Err(error(""))
+    Err(internal(""))
 }
 
 fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult<()> {
@@ -135,14 +135,14 @@ fn walk_tree(pwd: &Path, walk: |io::fs::File| -> CargoResult<()>) -> CargoResult
     loop {
         let possible = current.join(".cargo").join("config");
         if possible.exists() {
-            let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| error("could not open file")));
+            let file = cargo_try!(io::fs::File::open(&possible).chain_error(|| internal("could not open file")));
             match walk(file) {
                 Err(_) => err = false,
                 _ => ()
             }
         }
 
-        if err { return Err(error("")); }
+        if err { return Err(internal("")); }
         if !current.pop() { break; }
     }
 
@@ -153,12 +153,12 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult<ConfigValue> {
     let path = file.path().clone();
     let mut buf = io::BufferedReader::new(file);
     let root = cargo_try!(toml::parse_from_buffer(&mut buf));
-    let val = cargo_try!(root.lookup(key).require(|| error("")));
+    let val = cargo_try!(root.lookup(key).require(|| internal("")));
 
     let v = match val {
         &toml::String(ref val) => String(val.clone()),
         &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
-        _ => return Err(error(""))
+        _ => return Err(internal(""))
     };
 
     Ok(ConfigValue{ value: v, path: vec!(path) })
@@ -168,10 +168,10 @@ fn extract_all_configs(file: io::fs::File, map: &mut HashMap<String, ConfigValue
     let path = file.path().clone();
     let mut buf = io::BufferedReader::new(file);
     let root = cargo_try!(toml::parse_from_buffer(&mut buf).chain_error(||
-        error(format!("could not parse Toml manifest; path={}", path.display()))));
+        internal(format!("could not parse Toml manifest; path={}", path.display()))));
 
     let table = cargo_try!(root.get_table().require(||
-        error(format!("could not parse Toml manifest; path={}", path.display()))));
+        internal(format!("could not parse Toml manifest; path={}", path.display()))));
 
     for (key, value) in table.iter() {
         match value {
@@ -182,7 +182,7 @@ fn extract_all_configs(file: io::fs::File, map: &mut HashMap<String, ConfigValue
                 });
 
                 cargo_try!(merge_array(config, val.as_slice(), &path).chain_error(||
-                    error(format!("The `{}` key in your config", key))));
+                    internal(format!("The `{}` key in your config", key))));
             },
             _ => ()
         }
@@ -193,11 +193,11 @@ fn extract_all_configs(file: io::fs::File, map: &mut HashMap<String, ConfigValue
 
 fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &Path) -> CargoResult<()> {
     match existing.value {
-        String(_) => return Err(error("should be an Array, but it was a String")),
+        String(_) => return Err(internal("should be an Array, but it was a String")),
         List(ref mut list) => {
             let new_list: Vec<CargoResult<String>> = val.iter().map(|s: &toml::Value| toml_string(s)).collect();
             if new_list.iter().any(|v| v.is_err()) {
-                return Err(error("should be an Array of Strings, but was an Array of other values"));
+                return Err(internal("should be an Array of Strings, but was an Array of other values"));
             } else {
                 let new_list: Vec<String> = new_list.move_iter().map(|v| v.unwrap()).collect();
                 list.push_all(new_list.as_slice());
@@ -211,6 +211,6 @@ fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &Path) ->
 fn toml_string(val: &toml::Value) -> CargoResult<String> {
     match val {
         &toml::String(ref str) => Ok(str.clone()),
-        _ => Err(error(""))
+        _ => Err(internal(""))
     }
 }
index adad8a8db13b87a97867fde33929298c4bfe4bc6..ff716fda3e453d31f18d6bc7570ef42f3b98756f 100644 (file)
@@ -236,7 +236,7 @@ pub fn internal_error<S1: Str, S2: Str>(error: S1, detail: S2) -> Box<CargoError
     } as Box<CargoError>
 }
 
-pub fn error<S1: Str>(error: S1) -> Box<CargoError> {
+pub fn internal<S1: Str>(error: S1) -> Box<CargoError> {
     box ConcreteCargoError {
         description: error.as_slice().to_str(),
         detail: None,
index 1de113644a5c3d0094f27c108b6703e197e996e5..e88e9bfdc4643b905d88bc5858883e0e98bdf852 100644 (file)
@@ -2,7 +2,7 @@ pub use self::config::Config;
 pub use self::process_builder::{process,ProcessBuilder};
 pub use self::result::{Wrap, Require};
 pub use self::errors::{CargoResult, CargoError, BoxError, ChainError, CliResult, CliError, ProcessError};
-pub use self::errors::{process_error, internal_error, error, human, chain};
+pub use self::errors::{process_error, internal_error, internal, human, chain};
 pub use self::paths::realpath;
 
 pub mod graph;
index 413ba1a7cc104cf2a33e331eed9f1495ace7c65d..6312dc1a58cdc6f5aef566acfd76d27fb989e03e 100644 (file)
@@ -7,11 +7,11 @@ use serialize::Decodable;
 use core::{SourceId,GitKind};
 use core::manifest::{LibKind,Lib};
 use core::{Summary,Manifest,Target,Dependency,PackageId};
-use util::{CargoResult, Require, error, human};
+use util::{CargoResult, Require, human};
 
 pub fn to_manifest(contents: &[u8], source_id: &SourceId) -> CargoResult<(Manifest, Vec<Path>)> {
-    let root = try!(toml::parse_from_bytes(contents).map_err(|_| error("Cargo.toml is not valid Toml")));
-    let toml = try!(toml_to_manifest(root).map_err(|_| error("Cargo.toml is not a valid manifest")));
+    let root = try!(toml::parse_from_bytes(contents).map_err(|_| human("Cargo.toml is not valid Toml")));
+    let toml = try!(toml_to_manifest(root).map_err(|_| human("Cargo.toml is not a valid manifest")));
 
     toml.to_manifest(source_id)
 }