From f00c223d3a5e35559934549b9a10e83d02f18e42 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 16 May 2017 08:03:36 -0700 Subject: [PATCH] Use a few more `chain_error` calls --- src/cargo/core/workspace.rs | 10 +++++----- src/cargo/util/errors.rs | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index fd8531540f8..80313728eee 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -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. @@ -549,12 +549,12 @@ fn expand_member_path(path: &Path) -> CargoResult> { 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() } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 3b1d35b6eee..dec97d0fe40 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -11,6 +11,7 @@ use core::TargetKind; use curl; use git2; +use glob; use semver; use serde_json; use term; @@ -370,6 +371,8 @@ from_error! { term::Error, num::ParseIntError, str::ParseBoolError, + glob::PatternError, + glob::GlobError, } impl From for Box { @@ -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