Skip to content

Commit

Permalink
Use a few more chain_error calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 16, 2017
1 parent ea2df45 commit f00c223
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use glob::glob;
use core::{Package, VirtualManifest, EitherManifest, SourceId};
use core::{PackageIdSpec, Dependency, Profile, Profiles};
use ops;
use util::{Config, CargoResult, Filesystem, human};
use util::{Config, CargoResult, Filesystem, human, ChainError};
use util::paths;

/// The core abstraction in Cargo for working with a workspace of crates.
Expand Down Expand Up @@ -549,12 +549,12 @@ fn expand_member_path(path: &Path) -> CargoResult<Vec<PathBuf>> {
Some(p) => p,
None => return Ok(Vec::new()),
};
let res = glob(path).map_err(|e| {
human(format!("could not parse pattern `{}`: {}", &path, e))
let res = glob(path).chain_error(|| {
human(format!("could not parse pattern `{}`", &path))
})?;
res.map(|p| {
p.or_else(|e| {
Err(human(format!("unable to match path to pattern `{}`: {}", &path, e)))
p.chain_error(|| {
human(format!("unable to match path to pattern `{}`", &path))
})
}).collect()
}
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use core::TargetKind;

use curl;
use git2;
use glob;
use semver;
use serde_json;
use term;
Expand Down Expand Up @@ -370,6 +371,8 @@ from_error! {
term::Error,
num::ParseIntError,
str::ParseBoolError,
glob::PatternError,
glob::GlobError,
}

impl From<string::ParseError> for Box<CargoError> {
Expand Down Expand Up @@ -401,6 +404,8 @@ impl CargoError for ffi::NulError {}
impl CargoError for term::Error {}
impl CargoError for num::ParseIntError {}
impl CargoError for str::ParseBoolError {}
impl CargoError for glob::PatternError {}
impl CargoError for glob::GlobError {}

// =============================================================================
// Construction helpers
Expand Down

0 comments on commit f00c223

Please sign in to comment.