-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error-chain errors. #4090
Merged
Merged
Add error-chain errors. #4090
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b1b6973
Add error-chain errors
jluner e95044e
Add error-chain errors
jluner 5d7ac0d
Merge branch 'master' of https://github.com/jluner/cargo
jluner c7de485
Addresses review comments
jluner 2f3955a
Fix failing tests
jluner 6e9161b
Merge remote-tracking branch 'upstream/master'
jluner d121e05
Update gcc dependency to match updated gcc elsewhere in cargo
jluner 3c91570
Fix formatting issue blocking build
jluner 84667a1
Merge remote-tracking branch 'upstream/master'
jluner 7f6dbc1
Resolve upstream updates to referenced crates
jluner 68f5584
Restore macro_use
jluner def249f
Fixes review comments
jluner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ use std::fs; | |
use std::path::{Path, PathBuf}; | ||
|
||
use cargo::core::shell::{Verbosity, ColorConfig}; | ||
use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult}; | ||
use cargo::util::{self, CliResult, lev_distance, Config, CargoResult, CargoError, CargoErrorKind}; | ||
use cargo::util::CliError; | ||
|
||
#[derive(RustcDecodable)] | ||
|
@@ -84,7 +84,9 @@ fn main() { | |
let result = (|| { | ||
let args: Vec<_> = try!(env::args_os() | ||
.map(|s| { | ||
s.into_string().map_err(|s| human(format!("invalid unicode in argument: {:?}", s))) | ||
s.into_string().map_err(|s| { | ||
CargoError::from(format!("invalid unicode in argument: {:?}", s)) | ||
}) | ||
}) | ||
.collect()); | ||
let rest = &args; | ||
|
@@ -180,7 +182,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult { | |
|
||
if let Some(ref code) = flags.flag_explain { | ||
let mut procss = config.rustc()?.process(); | ||
procss.arg("--explain").arg(code).exec().map_err(human)?; | ||
procss.arg("--explain").arg(code).exec()?; | ||
return Ok(()); | ||
} | ||
|
||
|
@@ -309,7 +311,7 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[String]) -> C | |
let command = match path { | ||
Some(command) => command, | ||
None => { | ||
return Err(human(match find_closest(config, cmd) { | ||
return Err(CargoError::from(match find_closest(config, cmd) { | ||
Some(closest) => { | ||
format!("no such subcommand: `{}`\n\n\tDid you mean `{}`?\n", | ||
cmd, | ||
|
@@ -330,11 +332,12 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[String]) -> C | |
Err(e) => e, | ||
}; | ||
|
||
if let Some(code) = err.exit.as_ref().and_then(|c| c.code()) { | ||
Err(CliError::code(code)) | ||
} else { | ||
Err(CliError::new(Box::new(err), 101)) | ||
if let CargoError(CargoErrorKind::ProcessErrorKind(ref perr), ..) = err { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a |
||
if let Some(code) = perr.exit.as_ref().and_then(|c| c.code()) { | ||
return Err(CliError::code(code)); | ||
} | ||
} | ||
Err(CliError::new(err, 101)) | ||
} | ||
|
||
/// List all runnable commands | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where possible I tend to find
format!(...).into()
a little more ergonomic than wrapping withCargoError::from
, but that's not always possible due to inference issues.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many cases the compiler was just not figuring it out. I can do another pass to make sure
into
doesn't work. Is there a preference between a turbofishedinto
andfrom
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah unfortunately
into
doesn't work w/ turbofish as the type parameter is in the wrong place, if.into()
doesn't work thenCargoError::from
is fine, no worries!