let source_id = SourceId::for_path(&Path::new(options.manifest_path.as_slice()));
let mut source = PathSource::new(&source_id);
- try!(source.update().map_err(|err| CLIError::new(err.get_desc(), Some(err.get_detail()), 1)));
+ try!(source.update().map_err(|err| CliError::new(err.description(), 1)));
source
.get_root_package()
use serialize::Encodable;
use cargo::{NoFlags,execute_main_without_stdin,handle_error};
use cargo::util::important_paths::find_project;
-use cargo::util::{CliError, CliResult, CargoResult, CargoError, Require, config, box_error};
+use cargo::util::{CliError, CliResult, Require, config};
fn main() {
execute();
}
fn config_for_key(args: ConfigForKeyFlags) -> CliResult<Option<ConfigOut>> {
- let value = try!(config::get_config(os::getcwd(), args.key.as_slice()).map_err(|err|
+ let value = try!(config::get_config(os::getcwd(), args.key.as_slice()).map_err(|_|
CliError::new("Couldn't load configuration", 1)));
if args.human {
}
fn config_list(args: ConfigListFlags) -> CliResult<Option<ConfigOut>> {
- let configs = try!(config::all_configs(os::getcwd()).map_err(|e|
+ let configs = try!(config::all_configs(os::getcwd()).map_err(|_|
CliError::new("Couldn't load configuration", 1)));
if args.human {
Summary
};
use core::dependency::SerializedDependency;
-use util::{CargoResult, CargoError, box_error};
+use util::{CargoResult, box_error};
#[deriving(PartialEq,Clone)]
pub struct Manifest {
fn json_from_stdin<T: RepresentsJSON>() -> CliResult<T> {
let mut reader = io::stdin();
- let input = try!(reader.read_to_str().map_err(|e| CliError::new("Standard in did not exist or was not UTF-8", 1)));
+ let input = try!(reader.read_to_str().map_err(|_| CliError::new("Standard in did not exist or was not UTF-8", 1)));
- let json = try!(json::from_str(input.as_slice()).map_err(|e| CliError::new("Could not parse standard in as JSON", 1)));
+ let json = try!(json::from_str(input.as_slice()).map_err(|_| CliError::new("Could not parse standard in as JSON", 1)));
let mut decoder = json::Decoder::new(json);
- Decodable::decode(&mut decoder).map_err(|e: json::DecoderError| CliError::new("Could not process standard in as input", 1))
+ Decodable::decode(&mut decoder).map_err(|_| CliError::new("Could not process standard in as input", 1))
}
use std::io::File;
use util;
use core::{Package,Manifest,SourceId};
-use util::{CargoResult, CargoError, box_error, human};
+use util::{CargoResult, box_error, human};
pub fn read_manifest(contents: &[u8], source_id: &SourceId) -> CargoResult<(Manifest, Vec<Path>)> {
util::toml::to_manifest(contents, source_id).map_err(human)
use std::os::args;
use std::io;
use std::path::Path;
-use std::str;
use core::{Package,PackageSet,Target};
use util;
-use util::{CargoResult, CargoError, ProcessBuilder, error, human, box_error};
+use util::{CargoResult, CargoError, ProcessBuilder, error, human};
type Args = Vec<String>;
let rustc = prepare_rustc(root, target, *crate_type, dest, deps);
- try!((if verbose {
+ try!(if verbose {
rustc.exec().map_err(|err| {
log!(5, "exec failed; error={}", err.description());
human(err)
log!(5, "exec_with_output failed; error={}", err.description());
human(err)
})
- }));
+ });
}
Ok(())
fn clone_repo(&self) -> CargoResult<()> {
let dirname = Path::new(self.location.dirname());
- try!(mkdir_recursive(&dirname, UserDir).map_err(|e|
+ try!(mkdir_recursive(&dirname, UserDir).map_err(|_|
box_error(format!("Couldn't mkdir {}", Path::new(self.location.dirname()).display()))));
if self.location.exists() {
- try!(rmdir_recursive(&self.location).map_err(|e|
+ try!(rmdir_recursive(&self.location).map_err(|_|
box_error(format!("Couldn't rmdir {}", Path::new(&self.location).display()))));
}
}
fn git_output(path: &Path, str: String) -> CargoResult<String> {
- let output = try!(git(path, str.as_slice()).exec_with_output().map_err(|err|
+ let output = try!(git(path, str.as_slice()).exec_with_output().map_err(|_|
box_error(format!("Executing `git {}` failed", str))));
Ok(to_str(output.output.as_slice()).as_slice().trim_right().to_str())
log!(5, "get_root_package; source={}", self);
if !self.updated {
- return Err(simple_human("source has not been updated"))
+ return Err(box_error("source has not been updated"))
}
match self.packages.as_slice().head() {
}
}
+
impl Show for Box<CargoError> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "{}", self.description()));
}
pub struct ProcessError {
+ pub msg: String,
pub command: String,
pub exit: Option<ProcessExit>,
pub output: Option<ProcessOutput>,
Some(ExitStatus(i)) | Some(ExitSignal(i)) => i.to_str(),
None => "never executed".to_str()
};
- format!("Executing `{}` failed (status={})", self.command, exit)
+ format!("{} (status={})", self.msg, exit)
}
fn detail(&self) -> Option<String> {
}
}
-struct ConcreteCargoError {
+pub struct ConcreteCargoError {
description: String,
detail: Option<String>,
cause: Option<Box<CargoError>>,
pub fn process_error<S: Str>(msg: S, command: &Command, status: Option<&ProcessExit>, output: Option<&ProcessOutput>) -> ProcessError {
ProcessError {
+ msg: msg.as_slice().to_str(),
command: command.to_str(),
exit: status.map(|o| o.clone()),
output: output.map(|o| o.clone()),
use std::os;
use std::path::Path;
use std::io::process::{Command,ProcessOutput,InheritFd};
-use util::{CargoResult, CargoError, ProcessError, process_error, box_error};
+use util::{ProcessError, process_error};
use std::collections::HashMap;
#[deriving(Clone,PartialEq)]
let msg = || format!("Could not execute process `{}`", self.debug_string());
- let exit = try!(command.status().map_err(|e| process_error(msg(), &command, None, None)));
+ let exit = try!(command.status().map_err(|_| process_error(msg(), &command, None, None)));
if exit.success() {
Ok(())
let msg = || format!("Could not execute process `{}`", self.debug_string());
- let output = try!(command.output().map_err(|e| process_error(msg(), &command, None, None)));
+ let output = try!(command.output().map_err(|_| process_error(msg(), &command, None, None)));
if output.status.success() {
Ok(output)
use std::fmt::Show;
use ham = hamcrest;
use cargo::core::shell;
-use cargo::util::{process,ProcessBuilder,CargoError};
+use cargo::util::{process,ProcessBuilder};
use cargo::util::ProcessError;
pub mod paths;
assert_that(p.cargo_process("cargo-compile"),
execs()
.with_status(101)
- .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n ^~~~~~~\nExecuting `rustc 'src/foo.rs' '--crate-type' 'bin' '--out-dir' '{}' '-L' '{}'` failed (status=101)", target.display(), target.join("deps").display()).as_slice()));
+ .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n ^~~~~~~\nCould not execute process `rustc src/foo.rs --crate-type bin --out-dir {} -L {}` (status=101)", target.display(), target.join("deps").display()).as_slice()));
})
test!(cargo_compile_with_warnings_in_the_root_package {
use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
use hamcrest::{assert_that,existing_file};
use cargo;
-use cargo::util::{CargoResult, ProcessError, process};
+use cargo::util::{ProcessError, process};
fn setup() {
}